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

Needless escapes in Markdown since 2.1.1 #66

Closed
4 tasks done
kawanet opened this issue Nov 21, 2024 · 6 comments
Closed
4 tasks done

Needless escapes in Markdown since 2.1.1 #66

kawanet opened this issue Nov 21, 2024 · 6 comments
Labels
👯 no/duplicate Déjà vu 👎 phase/no Post cannot or will not be acted on

Comments

@kawanet
Copy link

kawanet commented Nov 21, 2024

Initial checklist

Affected packages and versions

mdast-util-to-markdown

Link to runnable example

No response

Steps to reproduce

import {fromMarkdown} from 'mdast-util-from-markdown'
import {toMarkdown} from 'mdast-util-to-markdown'
import {toHast} from 'mdast-util-to-hast'
import {toHtml} from 'hast-util-to-html'

const md = `foo***bar***buz`;
console.log(md) // original
console.log(toMarkdown(fromMarkdown(md))) // round trip
console.log(toHtml(toHast(fromMarkdown(md)))) // HTML

Expected behavior

until mdast-util-to-markdown version 2.1.0, or commit df0d6a6, it works correctly.
toMarkdown(fromMarkdown(md)) runs the round trip from Markdown to Markdown.

foo***bar***buz
foo***bar***buz
<p>foo<em><strong>bar</strong></em>buz</p>

Actual behavior

since mdast-util-to-markdown version 2.1.1, or commit 97fb818, it made characters escaped needlessly just before and after both * and **.
toMarkdown(fromMarkdown(md)) cannot run the round trip from Markdown to Markdown.
toHtml(toHast(fromMarkdown(md))) still has no trouble on the other hand.

foo***bar***buz
fo&#x6F;***bar***&#x62;uz
<p>foo<em><strong>bar</strong></em>buz</p>

It means version 2.1.1 has a breaking change. Version 2.1.2 has the same issue.
Thank you maintaining this anyway.

Affected runtime and version

[email protected]

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Nov 21, 2024
@wooorm
Copy link
Member

wooorm commented Nov 21, 2024

Hi! This looks like a duplicate of #65!

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2024
@wooorm wooorm added the 👯 no/duplicate Déjà vu label Nov 21, 2024

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Nov 21, 2024
@kawanet
Copy link
Author

kawanet commented Nov 21, 2024

Thank you for pointing me to the related issue.
My actual production app is to generate Markdown from mdast object without parsing Markdown.
I'll then try to update the app to add leading/trailing spaces around strong nodes to avoid the needless escaping.

The commit 97fb818 might be able to give the new minor version number 2.2.0 with the breaking change, by the way.

  • 1.5.0 - fo&#x6F;***bar***&#x62;uz
  • 2.0.0 - foo***bar***buz 😍
  • 2.1.0 - foo***bar***buz 😍
  • 2.1.1 - fo&#x6F;***bar***&#x62;uz 😢
  • 2.1.2 - fo&#x6F;***bar***&#x62;uz 😢

@wooorm
Copy link
Member

wooorm commented Nov 21, 2024

It depends on what you do, what I’d recommend. If you can generate spaces, I would indeed strongly recommend them.

Note that I do not consider escaping things a breaking change; that markdown still renders the same, and the HTML output is still the same. That wasn’t the case before. That escape is not needed in some cases. But it is needed in other cases. This patch fixes actual bugs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👯 no/duplicate Déjà vu 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants