8000 to_commonmark produces invalid sequence of bold/italic text · Issue #363 · gjtorikian/commonmarker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
to_commonmark produces invalid sequence of bold/italic text #363
Open
@sstur

Description

@sstur

In spec-compliant CommonMark the sequence **Hello** is a valid span of bold text, however **Hello ** (notice the trailing space) is not a valid span of bold text, it's two literal asterisks followed by some text and then two more literal asterisks.

This is expected, it's in the spec.

If you need a trailing space within a span of bold (or italic for that matter) you can escape it using an html-style escape sequence like **Hello **.

The commonmarker gem parses all three of these correctly.

However if you parse **Hello ** (or manually construct the equivalent AST) and then render it to_commonmark, this library will NOT render the correct markdown.

markdown = '**Hello **'
doc = Commonmarker.parse(markdown)
puts doc.to_commonmark # outputs the wrong thing: **Hello **

Parsing the output again back to an AST completely loses the bold text.

You can find a minimal repro here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0