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

Line break immediately after <pre> disappears #79

Open
akabekobeko opened this issue Apr 8, 2021 · 2 comments
Open

Line break immediately after <pre> disappears #79

akabekobeko opened this issue Apr 8, 2021 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@akabekobeko
Copy link
Member

Issue Details

A new issue I found while trying to fix #77.

  • VFM version
    • 1.0.0-alpha.17
  • Node.js version
    • 15.13.0

Expected Behavior

Markdown

<pre>
*    *    *
   *    *    *
</pre>

to HTML

<pre>
*    *    *
   *    *    *
</pre>

Actual Behavior

Line break immediately after <pre> disappears.

<pre>*    *    *
   *    *    *
</pre>

commonmark.js demo keeps line breaks as expected.

@akabekobeko akabekobeko added the bug Something isn't working label Apr 8, 2021
@akabekobeko akabekobeko added this to the v1.0.0 milestone Apr 8, 2021
@akabekobeko akabekobeko self-assigned this Apr 8, 2021
@akabekobeko
Copy link
Member Author

最小構成で実装してみた。

import unified from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import refypeRaw from 'rehype-raw'
import rehypeStringify from 'rehype-stringify'

const main = () => {
  const md = `<pre>
*    *    *
   *    *    *
</pre>`

  unified()
    .use(remarkParse)
    .use(remarkRehype, { allowDangerousHtml: true })
    .use(refypeRaw)
    .use(rehypeStringify)
    .process(md, (err, file) => {
      if (err) {
        console.error(err)
      } else {
        console.log(String(file))
      }
    })
}

main()

これを実行した結果は以下。

<pre>*    *    *
   *    *    *
</pre>

rehype-raw を外してみると HTML 開始タグは文字参照にエスケープされるが <pre> 直後の改行は維持されている。

&#x3C;pre>
*    *    *
   *    *    *
&#x3C;/pre>

以上ををまとめると

  • VFM で実装した箇所のバグではない
  • rehype-raw が原因

のようだ。

@akabekobeko
Copy link
Member Author

VFM 自体の問題ではないこと、VFM 2.0 で remark を刷新することにより周辺 npm も変更されるので改善される可能性もあるため、本件は次バージョン送りとする。

@akabekobeko akabekobeko modified the milestones: v1.0.0, v2.0.0 Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant