Skip to content

read: a bold or italic span starting or ending with punctuation reads back as literal asterisks #216

Description

@willkg

A bold, italic or strikethrough span whose text starts or ends with punctuation, with a letter or digit just outside it, reads back as literal asterisks. Reproduced on main:

storage read writes publish sends
<p>a<strong>(b)</strong>c</p> a**(b)**c <p>a**(b)**c</p>
<p><strong>&amp;copy;</strong>a</p> **\&copy;**a (since #203) literal asterisks

CommonMark's flanking rule has two halves. The whitespace half (a delimiter next to whitespace on the wrong side does not open or close) was fixed for marks in #204. The punctuation half remains: a closing ** preceded by punctuation closes only if it is followed by whitespace or punctuation, and an opening ** followed by punctuation opens only if it is preceded by whitespace or punctuation. So **(b)**c does not close, and the whole span publishes as text with its asterisks.

Escaping cannot fix it, since the punctuation is the span's own text. Possible fixes:

  • Write such a span as inline HTML (<strong>(b)</strong>), which goldmark passes through and the forward converter already accepts.
  • Use the _ delimiter where it helps. It has stricter intraword rules, so it is probably not a general answer.

Found while working on #203; the table property test's generator now keeps a mark's text from starting or ending with punctuation to avoid it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions