Skip to content

Commit

Permalink
Fix definition list tightness
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Feb 23, 2016
1 parent f68a7bd commit 4bc55ae
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -82,6 +82,7 @@ module.exports = function deflist_plugin(md) {

// Start list
listTokIdx = state.tokens.length;
tight = true;

token = state.push('dl_open', 'dl', 1);
token.map = listLines = [ startLine, 0 ];
Expand All @@ -102,7 +103,6 @@ module.exports = function deflist_plugin(md) {
/*eslint no-labels:0,block-scoped-var:0*/
OUTER:
for (;;) {
tight = true;
prevEmptyEnd = false;

token = state.push('dt_open', 'dt', 1);
Expand Down
53 changes: 53 additions & 0 deletions test/fixtures/deflist.txt
Expand Up @@ -103,6 +103,59 @@ Non-term 2
:</p>
.


List is tight iff all dts are tight:
.
Term 1
: foo
: bar

Term 2
: foo

: bar
.
<dl>
<dt>Term 1</dt>
<dd>
<p>foo</p>
</dd>
<dd>
<p>bar</p>
</dd>
<dt>Term 2</dt>
<dd>
<p>foo</p>
</dd>
<dd>
<p>bar</p>
</dd>
</dl>
.


Regression test (first paragraphs shouldn't be tight):
.
Term 1
: foo

bar
Term 2
: foo
.
<dl>
<dt>Term 1</dt>
<dd>
<p>foo</p>
<p>bar
Term 2</p>
</dd>
<dd>
<p>foo</p>
</dd>
</dl>
.

Definition lists should be second last in the queue. Exemplī grātiā, this isn't a valid one:

.
Expand Down

0 comments on commit 4bc55ae

Please sign in to comment.