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

Lines with only spaces are removed, even in code blocks #1884

Closed
u8sand opened this issue Dec 22, 2020 · 2 comments · Fixed by #1889
Closed

Lines with only spaces are removed, even in code blocks #1884

u8sand opened this issue Dec 22, 2020 · 2 comments · Fixed by #1889
Labels
L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue released

Comments

@u8sand
Copy link

u8sand commented Dec 22, 2020

Describe the bug

Spaces are removed from lines with only spaces. Though this might make some kind of sense for normal markdown, in code blocks it could be a problem in some esoteric programming languages such as whitespace but, perhaps more importantly, in real-time editing situations which is how it effects my use case.

To Reproduce

This caught me off guard because when I tried to fix it by extending the marked tokenizer, I found that the spaces were removed even there!

[
  {type:"code", raw:"```\nThis\n\nTest\n  .\n```", lang:"", text:"This\n\nTest\n  ."}
  //                           ^^^
]

The problem is the first line of the lexer blockTokens function:

src = src.replace(/^ +$/gm, '');

In my project I was forced to override the whole blockTokens function removing the first line. What would be the repercussions of removing it in general? Alternatively this could be an option..

Thanks for the great library!

@UziTech UziTech added the L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue label Dec 23, 2020
@UziTech
Copy link
Member

UziTech commented Dec 23, 2020

It looks like whitespace from blank lines was removed in the original markdown spec. Common Mark leaves them so I think we should only remove them when the pedantic option is used.

#1889 should fix this

@github-actions
Copy link

🎉 This issue has been resolved in version 1.2.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants