Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions lib/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,23 +607,20 @@ var blockStarts = [
.match(reSetextHeadingLine))
) {
parser.closeUnmatchedBlocks();
// resolve reference link definitiosn
// resolve reference link definitions on a copy, so the paragraph
// is left untouched if this turns out not to be a heading (#262)
var pos;
var content = container._string_content;
while (
peek(container._string_content, 0) === C_OPEN_BRACKET &&
(pos = parser.inlineParser.parseReference(
container._string_content,
parser.refmap
))
peek(content, 0) === C_OPEN_BRACKET &&
(pos = parser.inlineParser.parseReference(content, parser.refmap))
) {
container._string_content = container._string_content.slice(
pos
);
content = content.slice(pos);
}
if (container._string_content.length > 0) {
if (content.length > 0) {
var heading = new Node("heading", container.sourcepos);
heading.level = match[0][0] === "=" ? 1 : 2;
heading._string_content = container._string_content;
heading._string_content = content;
container.insertAfter(heading);
container.unlink();
parser.tip = heading;
Expand Down
39 changes: 39 additions & 0 deletions test/regression.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,42 @@ Entities inside autolinks (#263).
<pre><code class="language-js"></code></pre>
<pre><code class="language-js"></code></pre>
````````````````````````````````

Issue #262 - link reference definition followed by a setext underline
must not leave an empty paragraph behind.

```````````````````````````````` example
[a]: b
---
.
<hr />
````````````````````````````````

```````````````````````````````` example
[a]: b
===
.
<p>===</p>
````````````````````````````````

```````````````````````````````` example
[a]: b
---

[a]: b
===
.
<hr />
<p>===</p>
````````````````````````````````

```````````````````````````````` example
[a]: b
Foo
---

[a]
.
<h2>Foo</h2>
<p><a href="b">a</a></p>
````````````````````````````````
Loading