Skip to content

Commit

Permalink
Fix no end-of-file linefeed producing duplicates
Browse files Browse the repository at this point in the history
Closes GH-4.
Closes GH-5.

Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
  • Loading branch information
wooorm authored Aug 16, 2019
1 parent fe1b23d commit b929eb3
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function toNlcst(tree, file, Parser) {
} else if (child && start === -1) {
find(child)
start = index + 1
} else {
} else if (start !== -1) {
;(viable ? add : findAll)(children.slice(start, index))

if (child) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"parse-latin": "^4.0.0",
"prettier": "^1.0.0",
"rehype": "^9.0.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^5.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"vfile": "^4.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/eof-eol-missing-two-paragraphs/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>🤔</p><p></p>
117 changes: 117 additions & 0 deletions test/fixtures/eof-eol-missing-two-paragraphs/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"type": "RootNode",
"children": [
{
"type": "ParagraphNode",
"children": [
{
"type": "SentenceNode",
"children": [
{
"type": "SymbolNode",
"value": "🤔",
"position": {
"start": {
"line": 1,
"column": 4,
"offset": 3
},
"end": {
"line": 1,
"column": 6,
"offset": 5
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 4,
"offset": 3
},
"end": {
"line": 1,
"column": 6,
"offset": 5
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 4,
"offset": 3
},
"end": {
"line": 1,
"column": 6,
"offset": 5
}
}
},
{
"type": "ParagraphNode",
"children": [
{
"type": "SentenceNode",
"children": [
{
"type": "SymbolNode",
"value": "",
"position": {
"start": {
"line": 1,
"column": 13,
"offset": 12
},
"end": {
"line": 1,
"column": 14,
"offset": 13
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 13,
"offset": 12
},
"end": {
"line": 1,
"column": 14,
"offset": 13
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 13,
"offset": 12
},
"end": {
"line": 1,
"column": 14,
"offset": 13
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 18,
"offset": 17
}
}
}

0 comments on commit b929eb3

Please sign in to comment.