Skip to content

draft-to-markdown mistranslates spaces #150

Open
@Mark-Buxbaum

Description

@Mark-Buxbaum

Minor bug in draft-to-markdown: If you have a inline style that only surrounds spaces, the generated markdown misplaces the "close" token.

For example, if your text is hello there and the space in between the words hello and there has an inline-style of bold, the translated markdown is hello **there**.

I have a one-line fix for this. Add the boldfaced line below. (This fragment starts at draft-to-markdown.js:310)
if (character !== ' ' && markdownToAdd.length) {
markdownToAdd = markdownToAdd.filter(function(item) { return item.style.offset + item.style.length !== characterIndex });
markdownString += markdownToAdd.map(function (item) {
return item.value;
}).join('');

The filter keeps only the markdownToAdd elements that are not closed already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions