Skip to content

Commit

Permalink
Fix parsing of setext headers after ref link defs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Apr 7, 2019
1 parent 21279c4 commit 993bbe3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions lib/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,27 @@ var blockStarts = [
container.type === 'paragraph' &&
((match = parser.currentLine.slice(parser.nextNonspace).match(reSetextHeadingLine)))) {
parser.closeUnmatchedBlocks();
var heading = new Node('heading', container.sourcepos);
heading.level = match[0][0] === '=' ? 1 : 2;
heading._string_content = container._string_content;
container.insertAfter(heading);
container.unlink();
parser.tip = heading;
parser.advanceOffset(parser.currentLine.length - parser.offset, false);
return 2;
// resolve reference link definitiosn
var pos;
while (peek(container._string_content, 0) === C_OPEN_BRACKET &&
(pos =
parser.inlineParser.parseReference(
container._string_content, parser.refmap))) {
container._string_content =
container._string_content.slice(pos);
}
if (container._string_content.length > 0) {
var heading = new Node('heading', container.sourcepos);
heading.level = match[0][0] === '=' ? 1 : 2;
heading._string_content = container._string_content;
container.insertAfter(heading);
container.unlink();
parser.tip = heading;
parser.advanceOffset(parser.currentLine.length - parser.offset, false);
return 2;
} else {
return 0;
}
} else {
return 0;
}
Expand Down

0 comments on commit 993bbe3

Please sign in to comment.