You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it("should preserve bold, italics and underscore",()=>{constmarkdown1="Here's some *bold text*, some _italic text_, and some __underlined text__.";constast=remark().use(remarkParse).parse(markdown);constmarkdown2=remark().use(remarkStringify).stringify(ast);expect(markdown1).toEqual(markdown2);// Fails<<<});
// markdown1 == "Here's some *bold text*, some _italic text_, and some __underlined text__."// markdown2 == "Here's some *bold text*, some *italic text*, and some **underlined text**."
Expected behavior
Both bold and italics are parsed to become type: 'emphasis' in the AST so can't be unparsed via remark-stringify as it can't distinguish them and underlined becomes **underlined text**.
constmarkdown1="Here's some *bold text*, some _italic text_, and some __underlined text__.";constast=remark().use(remarkParse).parse(markdown);constmarkdown2=remark().use(remarkStringify).stringify(ast);
I expected remarkParse to be reversable by remarkStringify however we get his result:
// markdown1 == "Here's some *bold text*, some _italic text_, and some __underlined text__."// markdown2 == "Here's some *bold text*, some *italic text*, and some **underlined text**."
I'm testing using vitest
Affected runtime and version
node@18.18.0
Affected package manager and version
yarn@122.19
Affected OS and version
Windows 10
Build and bundle tools
Vite
The text was updated successfully, but these errors were encountered:
Welcome @ptc-tonyo! 👋
Sorry you ran into some confusion.
A good starting point would be understand what Markdown is and what it supports quick version: https://commonmark.org/help/ more formal details: https://spec.commonmark.org/0.30/#emphasis-and-strong-emphasis
Emphasis is surrounded by a single * or _ on either side.
Bold text is surrounded by two ** or __ on either side.
There is no underline construct in markdown.
remark/mdast-util-from-markdown will preserve valid and supported markdown structure.
remark/micromark/mdast-util-from-markdown do support extending markdown with new syntax.
Creating your own custom markdown-like flavor that is only supported by your application is not generally advisable, but is possible https://github.com/micromark/micromark#extending-markdown
Initial checklist
Affected packages and versions
mdast-util-to-markdown "^2.0.0" => "remark": "^15.0.1", "remark-parse": "^11.0.0", "remark-stringify": "^11.0.0",
Link to runnable example
No response
Steps to reproduce
This unit test fails:
Expected behavior
Both bold and italics are parsed to become
type: 'emphasis'
in the AST so can't be unparsed via remark-stringify as it can't distinguish them and underlined becomes**underlined text**
.Actual behavior
I expected
remarkParse
to be reversable byremarkStringify
however we get his result:I'm testing using vitest
Affected runtime and version
node@18.18.0
Affected package manager and version
yarn@122.19
Affected OS and version
Windows 10
Build and bundle tools
Vite
The text was updated successfully, but these errors were encountered: