Skip to content

Commit

Permalink
Resolves #1618, preserve the markup if it's the last element
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie committed Mar 14, 2019
1 parent f2d8e1c commit b16ecae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/keep-markup/prism-keep-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}

} else if (child.nodeType === 3) { // text
if(!nodeState.nodeStart && nodeState.pos + child.data.length > nodeState.node.posOpen) {
if(!nodeState.nodeStart && nodeState.pos + child.data.length >= nodeState.node.posOpen) {
// We found the start position
nodeState.nodeStart = child;
nodeState.nodeStartPos = nodeState.node.posOpen - nodeState.pos;
Expand Down
2 changes: 0 additions & 2 deletions tests/plugins/keep-markup/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ describe('Prism Keep Markup Plugin', function () {
})
// The markup is removed if it's the last element and the element's name is a single letter: a(nchor), b(old), i(talic)...
// https://github.com/PrismJS/prism/issues/1618
/*
it('should keep last single letter empty markup', function () {
const result = execute(`<code class="language-javascript">xy<a></a></code>`)
expect(result.start.length).to.equal(1)
expect(result.end.length).to.equal(1)
expect(result.nodes.length).to.equal(1)
expect(result.nodes[0].nodeName).to.equal('A')
})
*/
})

0 comments on commit b16ecae

Please sign in to comment.