Skip to content

Italics with underscores (e.g. _a_) don't render correctly with short strings (1 and 2 chars) #1188

Closed
@kaelig

Description

@kaelig

Note: could be a duplicate of #1178 (the following issue may be more detailed though)

Marked version: 0.3.19

Markdown flavor: not sure

What pain point are you perceiving?

Short strings in italics don't render properly:

_a_

_ab_

See https://marked.js.org/demo/?text=Short%20strings%20in%20italics%20don%27t%20render%0A%0A_a_%0A%0A_ab_%0A%0AAll%20of%20these%20do%20render%20properly%3A%0A%0A*%20_abc_%0A*%20*a*%0A*%20*ab*%0A*%20*abc*%0A*%20__a__%0A*%20__ab__%0A*%20__abc__%0A*%20**a**%0A*%20**ab**%0A*%20**abc**%0A

What solution are you suggesting?

n/a

Expectation

<p><em>a</em></p>
<p><em>ab</em></p>

Result

<p>_a_</p>
<p>_ab_</p>

What was attempted

The workaround is to use * instead of _ to wrap italics. Unfortunately, formatters like Prettier enforces _ so you end up with having to do this (works in Prettier 1.12+):

<!-- prettier-ignore-start -->

_a_

_ab_

<!-- prettier-ignore-end -->

Or this if you're using prettier < 1.12

<i>a<i>

<i>ab</i>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions