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

Fix splitting delimiter runs #261

Open
bachbui opened this issue Oct 22, 2019 · 0 comments
Open

Fix splitting delimiter runs #261

bachbui opened this issue Oct 22, 2019 · 0 comments
Labels
🐞 Bug This is identified as a bug or is fixing a bug

Comments

@bachbui
Copy link
Contributor

bachbui commented Oct 22, 2019

We have a utility in our Commonmark renderer to adjust the boundaries of certain annotations when they would produce an invalid delimiter run. This logic had assumed that the rules for valid delimiter runs were the same regardless of what the specific delimiter character was, but this is not the case.

Here are the rules for delimiters, from least to most restrictive:

If the delimiter is ^ or ~:

  • the inner boundary must not be a whitespace character

If the delimiter is *, **, or ~~

  • the inner boundary for a delimiter run must not be a whitespace character
  • the outer boundary for a delimiter run must be a whitespace or punctuation character if the inner boundary is a punctuation character

If the delimiter run is _ or __

  • the inner boundary for a delimiter run must not be a whitespace character
  • the outer boundary for a delimiter run must be a whitespace or punctuation character

Here are some examples of the correct behavior. Here square brackets represent the delimiter boundary, an underscore represents a whitespace character, and a dash represents a punctuation character:

Original Split for ^, ~ Split for *, **, ~~ Split for _, __
[_a_b] _[a_b] _[a_b] _[a_b]
a[-b] a[-b] a-[b] a-[b]
a[b_c] a[b_c] a[b_c] ab_[c]
a[bc] a[bc] a[bc] abc[]
@tim-evans tim-evans added the 🐞 Bug This is identified as a bug or is fixing a bug label Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug This is identified as a bug or is fixing a bug
Projects
None yet
Development

No branches or pull requests

2 participants