Skip to content

Commit

Permalink
Fix to merge blockquotes in gfm mode
Browse files Browse the repository at this point in the history
Closes GH-417.

Reviewed-by: Christian Murphy <[email protected]>
Reviewed-by: Marouane Fazouane <[email protected]>
Reviewed-by: Titus Wormer <[email protected]>
  • Loading branch information
arobase-che authored and wooorm committed Jul 10, 2019
1 parent 927083c commit 2f0edce
Show file tree
Hide file tree
Showing 7 changed files with 508 additions and 112 deletions.
4 changes: 2 additions & 2 deletions packages/remark-parse/lib/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ function mergeText(prev, node) {
return prev
}

// Merge two blockquotes: `node` into `prev`, unless in CommonMark mode.
// Merge two blockquotes: `node` into `prev`, unless in CommonMark or gfm modes.
function mergeBlockquote(prev, node) {
if (this.options.commonmark) {
if (this.options.commonmark || this.options.gfm) {
return node
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/input/blockquotes.text
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
> This is a blockquote.

> This is, in commonmark mode, another blockquote.
> This is, in commonmark mode and gfm mode, another blockquote.
16 changes: 8 additions & 8 deletions test/fixtures/tree/blockquotes.commonmark.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"children": [
{
"type": "text",
"value": "This is, in commonmark mode, another blockquote.",
"value": "This is, in commonmark mode and gfm mode, another blockquote.",
"position": {
"start": {
"line": 3,
Expand All @@ -71,8 +71,8 @@
},
"end": {
"line": 3,
"column": 51,
"offset": 75
"column": 64,
"offset": 88
},
"indent": []
}
Expand All @@ -86,8 +86,8 @@
},
"end": {
"line": 3,
"column": 51,
"offset": 75
"column": 64,
"offset": 88
},
"indent": []
}
Expand All @@ -101,8 +101,8 @@
},
"end": {
"line": 3,
"column": 51,
"offset": 75
"column": 64,
"offset": 88
},
"indent": []
}
Expand All @@ -117,7 +117,7 @@
"end": {
"line": 4,
"column": 1,
"offset": 76
"offset": 89
}
}
}
43 changes: 29 additions & 14 deletions test/fixtures/tree/blockquotes.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,31 @@
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 24,
"offset": 23
},
"indent": []
}
},
{
"type": "blockquote",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "This is, in commonmark mode, another blockquote.",
"value": "This is, in commonmark mode and gfm mode, another blockquote.",
"position": {
"start": {
"line": 3,
Expand All @@ -53,8 +71,8 @@
},
"end": {
"line": 3,
"column": 51,
"offset": 75
"column": 64,
"offset": 88
},
"indent": []
}
Expand All @@ -68,28 +86,25 @@
},
"end": {
"line": 3,
"column": 51,
"offset": 75
"column": 64,
"offset": 88
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"line": 3,
"column": 1,
"offset": 0
"offset": 25
},
"end": {
"line": 3,
"column": 51,
"offset": 75
"column": 64,
"offset": 88
},
"indent": [
1,
1
]
"indent": []
}
}
],
Expand All @@ -102,7 +117,7 @@
"end": {
"line": 4,
"column": 1,
"offset": 76
"offset": 89
}
}
}
Loading

0 comments on commit 2f0edce

Please sign in to comment.