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

Strikethrough does not work with a space just inside of it #520

Closed
thesunny opened this issue Jul 25, 2020 · 4 comments
Closed

Strikethrough does not work with a space just inside of it #520

thesunny opened this issue Jul 25, 2020 · 4 comments
Labels
👯 no/duplicate Déjà vu 🐛 type/bug This is a problem

Comments

@thesunny
Copy link

thesunny commented Jul 25, 2020

Subject of the issue

Strikethrough works in this scenario:

This is ~~text that has strikethrough~~ in it

But is parsed as plain text with the literal ~~ when there is a space in it

This is ~~text that has strikethrough ~~ in it and does not work (space at end)
This is ~~ text that has strikethrough~~ in it and this also does not work (space at front)

These two lines also render fine in GitHub:

Notably, bold and italic work find with spaces just inside the tokens.

Your environment

  • OS: Mac
  • Packages: remark-parse 8.0.3, unified 9.0.0
  • Env: Node 12.16.2

Steps to reproduce

Here is a minimal reproduction on GitHub.

Just clone, yarn and yarn start

git clone git@github.com:thesunny/remark-strikethrough.git
cd remark-strikethrough
yarn
yarn start

Expected behaviour

It should parse a strikethrough with a space in it as the formatting of a strikethrough

Actual behaviour

It parses it as literal text

@thesunny thesunny added 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Jul 25, 2020
@ChristianMurphy
Copy link
Member

@thesunny this is to spec.
You can try it on Github

You example

This is ~~text that has strikethrough ~~ in it and does not work (space at end)
This is ~~ text that has strikethrough~~ in it and this also does not work (space at front)

renders as


This is text that has strikethrough ~~ in it and does not work (space at end)
This is ~~ text that has strikethrough
in it and this also does not work (space at front)


which matches has remark parses it https://astexplorer.net/#/gist/9e65a4608b9e79c42eddbc5785d5c428/056450d5fa2badbd5f6051f266925a2b6c8975ef

You can find the spec here:
https://github.github.com/gfm/#emphasis-and-strong-emphasis
https://github.github.com/gfm/#strikethrough-extension-

@thesunny
Copy link
Author

Hmm... I'm looking at the source code and I see that this behavior seems intentional.

I also notice that GFM parses this the same way which is IMO broken. It also parses bold and italic this way which remark does not.

According to the GFM docs here:

https://github.github.com/gfm/#strikethrough-extension-

It doesn't mention any special behavior with respect to spaces just inside the tokens for strikethrough and seems to suggest that strikethrough should be parsed the same as emphasis. From their docs:

As with regular emphasis delimiters, a new paragraph will cause strikethrough parsing to cease:

In other words, it seems strikethrough should work the same as bold and italic.

I don't want to make things worse for myself, but bold and italic are broken in GFM. For example, if I type in this code in GitHub (ie. right here).

**bold **_italic _~~strikethrough ~~

**bold **_italic _~~strikethrough ~~

None of these work. But bold and italic work in remark but strikethrough does not.

My suggestion is we fix strikethrough to be consistent with bold and italic.

@ChristianMurphy
Copy link
Member

My suggestion is we fix strikethrough to be consistent with bold and italic.

See #306 and #504

#439 aims to resolve this

@ChristianMurphy ChristianMurphy added 👯 no/duplicate Déjà vu and removed 🐛 type/bug This is a problem 🙉 open/needs-info This needs some more info labels Jul 25, 2020
@thesunny
Copy link
Author

Thanks for the update @ChristianMurphy and thanks for the quick response.

@ChristianMurphy ChristianMurphy added the 🐛 type/bug This is a problem label Jul 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👯 no/duplicate Déjà vu 🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants