diff --git a/lib/markdownlint.js b/lib/markdownlint.js
index 36444d56..2183e95c 100644
--- a/lib/markdownlint.js
+++ b/lib/markdownlint.js
@@ -80,8 +80,21 @@ function lintContent(content, config, frontMatter) { // eslint-disable-line
var tokens = md.parse(content, {});
var lines = content.split(shared.newLineRe);
var tokenLists = {};
+ var tbodyMap = null;
// Annotate tokens with line/lineNumber
tokens.forEach(function forToken(token) {
+ // Handle missing maps for table body
+ if (token.type === "tbody_open") {
+ tbodyMap = token.map.slice();
+ } else if ((token.type === "tr_close") && tbodyMap) {
+ tbodyMap[0]++;
+ } else if (token.type === "tbody_close") {
+ tbodyMap = null;
+ }
+ if (tbodyMap && !token.map) {
+ token.map = tbodyMap.slice();
+ }
+ // Update token metadata
if (token.map) {
token.line = lines[token.map[0]];
token.lineNumber = token.map[0] + 1;
diff --git a/lib/rules.js b/lib/rules.js
index c19e4523..6b0f300b 100644
--- a/lib/rules.js
+++ b/lib/rules.js
@@ -464,11 +464,8 @@ module.exports = [
} else if (token.type === "inline") {
token.content.split(shared.newLineRe)
.forEach(function forLine(line, offset) {
- if (token.map && /^(-+|=+)\s*$/.test(line)) {
- var seTextLineNumber = token.map[0] + offset;
- if (seTextLineNumber > 0) {
- errors.push(seTextLineNumber);
- }
+ if (token.map && /^(-+|=+)\s*$/.test(line) && offset) {
+ errors.push(token.map[0] + offset);
}
});
}
diff --git a/test/md033-cannot-read-property-of-undefined.md b/test/md033-cannot-read-property-of-undefined.md
new file mode 100644
index 00000000..6a663739
--- /dev/null
+++ b/test/md033-cannot-read-property-of-undefined.md
@@ -0,0 +1,11 @@
+# Header
+
+Head | Head
+--------|------------
+
| {MD033}
+
+{MD033} | Head
+--------|------------
+
| {MD033}
+text | text
+{MD033} | text