remarkjs / remark-gfm

remark plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists)

Home Page:https://remark.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bold and strikethrough do not work when it's not an isolated word and has punctuation inside

taoky opened this issue · comments

commented

Subject of the issue

Bold (**) and strikethrought (~~) sometimes won't work properly when:

  • It is a non-isolated word.
  • There are (unicode) punctuation at the beginning or the end of the word inside ** / ~~

Your environment

  • OS: macOS 10.14.6
  • Packages:
    • remark 13.0.0
    • remark-gfm 1.0.0
    • remark-html 13.0.1
  • Env:
    • node 16.5.0
    • npm 7.19.1

Steps to reproduce

test.md:

测试~~(删除线)~~

测试 ~~(删除线)~~

Test~~(StrikeThrough)~~

测试,**粗体。**字符。

测试,**粗体。** 字符。

Test,**bold.**Character.

test.mjs

import remark from 'remark'
import gfm from 'remark-gfm'
import html from 'remark-html'
import fs from 'fs'

remark().use(gfm).use(html).process(fs.readFileSync("./test.md")).then(v => console.log(v.contents))

and node test.mjs

Expected behavior

It outputs:

<p>测试<del>(删除线)</del></p>
<p>测试 <del>(删除线)</del></p>
<p>Test<del>(StrikeThrough)</del></p>
<p>测试,<strong>粗体。</strong>字符。</p>
<p>测试,<strong>粗体。</strong> 字符。</p>
<p>Test,<strong>bold.</strong>Character.</p>

Actual behavior

<p>测试~~(删除线)~~</p>
<p>测试 <del>(删除线)</del></p>
<p>Test~~(StrikeThrough)~~</p>
<p>测试,**粗体。**字符。</p>
<p>测试,<strong>粗体。</strong> 字符。</p>
<p>Test,**bold.**Character.</p>

The current behavior matches the standard.

You can see it matches github


测试~~(删除线)~~

测试 (删除线)

Test~~(StrikeThrough)~~

测试,**粗体。**字符。

测试,粗体。 字符。

Test,**bold.**Character.


And where it is documented in the standards

https://spec.commonmark.org/0.30/#example-351
https://spec.commonmark.org/0.30/#example-352
https://github.github.com/gfm/#strikethrough-extension-

You are welcome to suggest a change to the standard https://talk.commonmark.org/

But in the meantime, it makes sense for remark gfm, to implement gfm 🙂