Skip to content

Commit

Permalink
Fix footnote definitions without spacing
Browse files Browse the repository at this point in the history
Previously, in the below example, the second definition was parsed as
a normal definition instead of a footnote definition:

```md
foo[^abc] bar. foo[^xyz] bar

[^abc]: Baz baz

[^xyz]: Baz
```

Now, both are seen as footnote definitions.

Closes GH-106.
  • Loading branch information
wooorm committed Dec 18, 2015
1 parent d8d4783 commit 18195f6
Show file tree
Hide file tree
Showing 7 changed files with 479 additions and 190 deletions.
2 changes: 1 addition & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5899,8 +5899,8 @@ Parser.prototype.blockMethods = [
'list',
'lineHeading',
'html',
'definition',
'footnoteDefinition',
'definition',
'looseTable',
'table',
'paragraph'
Expand Down
3 changes: 0 additions & 3 deletions test/input/footnote-like.text
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
This looks like a footnote, but is in fact, a [link][^link].
This one isn't even [defined][^foo].

[^link]: <~/foo/bar.baz>

[^both][invalid], [^this too][].
5 changes: 5 additions & 0 deletions test/input/footnote-without-space.text
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
foo[^abc] bar. foo[^xyz] bar

[^abc]: Baz baz

[^xyz]: Baz
117 changes: 24 additions & 93 deletions test/tree/footnote-like.footnotes.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,17 @@
"children": [
{
"type": "text",
"value": "This looks like a footnote, but is in fact, a ",
"value": "This one isn't even ",
"position": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 47
},
"indent": []
}
},
{
"type": "linkReference",
"identifier": "^link",
"referenceType": "full",
"children": [
{
"type": "text",
"value": "link",
"position": {
"start": {
"line": 1,
"column": 48
},
"end": {
"line": 1,
"column": 52
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"column": 47
},
"end": {
"line": 1,
"column": 60
},
"indent": []
}
},
{
"type": "text",
"value": ".\nThis one isn't even ",
"position": {
"start": {
"line": 1,
"column": 60
},
"end": {
"line": 2,
"column": 21
},
"indent": [
1
]
"indent": []
}
},
{
Expand All @@ -79,11 +29,11 @@
"value": "defined",
"position": {
"start": {
"line": 2,
"line": 1,
"column": 22
},
"end": {
"line": 2,
"line": 1,
"column": 29
},
"indent": []
Expand All @@ -92,11 +42,11 @@
],
"position": {
"start": {
"line": 2,
"line": 1,
"column": 21
},
"end": {
"line": 2,
"line": 1,
"column": 36
},
"indent": []
Expand All @@ -107,11 +57,11 @@
"value": ".",
"position": {
"start": {
"line": 2,
"line": 1,
"column": 36
},
"end": {
"line": 2,
"line": 1,
"column": 37
},
"indent": []
Expand All @@ -124,28 +74,9 @@
"column": 1
},
"end": {
"line": 2,
"line": 1,
"column": 37
},
"indent": [
1
]
}
},
{
"type": "definition",
"identifier": "^link",
"title": null,
"link": "~/foo/bar.baz",
"position": {
"start": {
"line": 4,
"column": 1
},
"end": {
"line": 4,
"column": 25
},
"indent": []
}
},
Expand All @@ -162,11 +93,11 @@
"value": "^both",
"position": {
"start": {
"line": 6,
"line": 3,
"column": 3
},
"end": {
"line": 6,
"line": 3,
"column": 8
},
"indent": []
Expand All @@ -175,11 +106,11 @@
],
"position": {
"start": {
"line": 6,
"line": 3,
"column": 1
},
"end": {
"line": 6,
"line": 3,
"column": 17
},
"indent": []
Expand All @@ -190,11 +121,11 @@
"value": ", ",
"position": {
"start": {
"line": 6,
"line": 3,
"column": 17
},
"end": {
"line": 6,
"line": 3,
"column": 19
},
"indent": []
Expand All @@ -210,11 +141,11 @@
"value": "^this too",
"position": {
"start": {
"line": 6,
"line": 3,
"column": 21
},
"end": {
"line": 6,
"line": 3,
"column": 30
},
"indent": []
Expand All @@ -223,11 +154,11 @@
],
"position": {
"start": {
"line": 6,
"line": 3,
"column": 19
},
"end": {
"line": 6,
"line": 3,
"column": 32
},
"indent": []
Expand All @@ -238,11 +169,11 @@
"value": ".",
"position": {
"start": {
"line": 6,
"line": 3,
"column": 32
},
"end": {
"line": 6,
"line": 3,
"column": 33
},
"indent": []
Expand All @@ -251,11 +182,11 @@
],
"position": {
"start": {
"line": 6,
"line": 3,
"column": 1
},
"end": {
"line": 6,
"line": 3,
"column": 33
},
"indent": []
Expand All @@ -268,7 +199,7 @@
"column": 1
},
"end": {
"line": 7,
"line": 4,
"column": 1
}
}
Expand Down
Loading

0 comments on commit 18195f6

Please sign in to comment.