Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft-to-markdown mistranslates spaces #150

Open
Mark-Buxbaum opened this issue Apr 23, 2021 · 0 comments
Open

draft-to-markdown mistranslates spaces #150

Mark-Buxbaum opened this issue Apr 23, 2021 · 0 comments

Comments

@Mark-Buxbaum
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant