Skip to content

Commit b5a7d15

Browse files
author
Rose Robertson
committed
Fix issue with surrogate pairs messing up links at EOL
The closing code for entity items was sometimes not run at the end of a block if the block text included emoji made up of multiple characters. In cases such as this. string.length !== Array.from(string).length, the latter being a more accurate representation of how many characters there actually are.
1 parent 93e0d36 commit b5a7d15

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/draft-to-markdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ function renderBlock(block, index, rawDraftObject, options) {
436436

437437
// Close any remaining entity tags
438438
block.entityRanges.forEach(function (range, rangeIndex) {
439-
if (range.offset + range.length === block.text.length) {
439+
if (range.offset + range.length === Array.from(block.text).length) {
440440
var entity = rawDraftObject.entityMap[range.key];
441441
if (customEntityItems[entity.type] || EntityItems[entity.type]) {
442442
markdownString += (customEntityItems[entity.type] || EntityItems[entity.type]).close(entity);

0 commit comments

Comments
 (0)