Skip to content

Commit

Permalink
Fix handling of definitions in commonmark-mode
Browse files Browse the repository at this point in the history
Definitions in commonmark-mode are not allowed to follow a
list-item:

```md
* [bar][].
[bar]: http://google.com
```

...should be rendered something like:

```md
* [bar][]. [bar]: http://google.com
```

Closes GH-111.
  • Loading branch information
wooorm committed Dec 22, 2015
1 parent 6e74759 commit b7d6e53
Show file tree
Hide file tree
Showing 17 changed files with 3,889 additions and 341 deletions.
5 changes: 2 additions & 3 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1872,15 +1872,14 @@ function tokenizeList(eat, value, silent) {
break;
}

// TODO: Should not be possible in commonmark.
// if (!commonmark) {
if (!commonmark) {
if (
tokenizers.definition.call(self, eat, line, true) ||
tokenizers.footnoteDefinition.call(self, eat, line, true)
) {
break;
}
// }
}

item.value = item.value.concat(emptyLines, line);
allLines = allLines.concat(emptyLines, line);
Expand Down
93 changes: 66 additions & 27 deletions test/tree/def-blocks.commonmark.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,65 @@
"children": [
{
"type": "text",
"value": "hello",
"value": "hello\n",
"position": {
"start": {
"line": 14,
"column": 3
},
"end": {
"line": 14,
"column": 8
"line": 15,
"column": 1
},
"indent": [
1
]
}
},
{
"type": "linkReference",
"identifier": "4",
"referenceType": "shortcut",
"children": [
{
"type": "text",
"value": "4",
"position": {
"start": {
"line": 15,
"column": 2
},
"end": {
"line": 15,
"column": 3
},
"indent": []
}
}
],
"position": {
"start": {
"line": 15,
"column": 1
},
"end": {
"line": 15,
"column": 4
},
"indent": []
}
},
{
"type": "text",
"value": ": hello",
"position": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 15,
"column": 11
},
"indent": []
}
Expand All @@ -405,10 +455,12 @@
"column": 3
},
"end": {
"line": 14,
"column": 8
"line": 15,
"column": 11
},
"indent": []
"indent": [
1
]
}
}
],
Expand All @@ -418,10 +470,12 @@
"column": 1
},
"end": {
"line": 14,
"column": 8
"line": 15,
"column": 11
},
"indent": []
"indent": [
1
]
}
}
],
Expand All @@ -430,28 +484,13 @@
"line": 14,
"column": 1
},
"end": {
"line": 14,
"column": 8
},
"indent": []
}
},
{
"type": "definition",
"identifier": "4",
"title": null,
"link": "hello",
"position": {
"start": {
"line": 15,
"column": 1
},
"end": {
"line": 15,
"column": 11
},
"indent": []
"indent": [
1
]
}
},
{
Expand Down
Loading

0 comments on commit b7d6e53

Please sign in to comment.