diff --git a/src/Tokenizer.js b/src/Tokenizer.js index 0eec752cc3..755a62d285 100644 --- a/src/Tokenizer.js +++ b/src/Tokenizer.js @@ -23,15 +23,14 @@ function outputLink(cap, link, raw, lexer) { }; lexer.state.inLink = false; return token; - } else { - return { - type: 'image', - raw, - href, - title, - text: escape(text) - }; } + return { + type: 'image', + raw, + href, + title, + text: escape(text) + }; } function indentCodeCompensation(raw, text) { @@ -130,7 +129,7 @@ export class Tokenizer { type: 'heading', raw: cap[0], depth: cap[1].length, - text: text, + text, tokens: [] }; this.lexer.inline(token.text, token.tokens); @@ -225,7 +224,8 @@ export class Tokenizer { } if (!endEarly) { - const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])`); + const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?: [^\\n]*)?(?:\\n|$))`); + const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`); // Check if following lines should be included in List Item while (src) { @@ -242,6 +242,11 @@ export class Tokenizer { break; } + // Horizontal rule found + if (hrRegex.test(src)) { + break; + } + if (line.search(/[^ ]/) >= indent || !line.trim()) { // Dedent if possible itemContents += '\n' + line.slice(indent); } else if (!blankLine) { // Until blank line, item doesn't need indentation @@ -279,7 +284,7 @@ export class Tokenizer { list.items.push({ type: 'list_item', - raw: raw, + raw, task: !!istask, checked: ischecked, loose: false, diff --git a/test/specs/new/list_item_unindented_asterisk.html b/test/specs/new/list_item_unindented_asterisk.html new file mode 100644 index 0000000000..6dfea000d7 --- /dev/null +++ b/test/specs/new/list_item_unindented_asterisk.html @@ -0,0 +1,24 @@ +