diff --git a/lib/md044.js b/lib/md044.js index 520f00f4..f49a8101 100644 --- a/lib/md044.js +++ b/lib/md044.js @@ -40,7 +40,14 @@ module.exports = { // Attempt to fix bad offset due to inline content matchIndex = fullLine.indexOf(wordMatch); } - const range = [ matchIndex + 1, matchLength ]; + const range = (matchIndex === -1) ? + null : + [ matchIndex + 1, matchLength ]; + const fixInfo = (matchIndex === -1) ? null : { + "editColumn": matchIndex + 1, + "deleteCount": matchLength, + "insertText": name + }; addErrorDetailIf( onError, lineNumber, @@ -49,11 +56,7 @@ module.exports = { null, null, range, - { - "editColumn": matchIndex + 1, - "deleteCount": matchLength, - "insertText": name - } + fixInfo ); } } diff --git a/test/proper-names.md b/test/proper-names.md index 637ce255..b4ca9f03 100644 --- a/test/proper-names.md +++ b/test/proper-names.md @@ -69,3 +69,15 @@ Bare URL exempt https://github.com/DavidAnson/MARKDOWNLINT {MD034} A short paragraph about node.js and {MD044} javascript. {MD044} + +{MD044} `javascript` + +{MD044} `code +javascript` + +{MD044} `code +javascript +code` + +{MD044} `javascript +code`