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

Inline code is rendered with extra or missing spaces at beginning or end #316

Closed
egrimley opened this issue Dec 19, 2019 · 2 comments
Closed

Comments

@egrimley
Copy link

If the inline code starts or ends with a space then strange things happen when rendering as CommonMark:

$ printf '` `' | cmark -t commonmark
`   `
$ printf '`  `' | cmark -t commonmark
`    `
$ printf '` x`' | cmark -t commonmark
`  x `
$ printf '`x `' | cmark -t commonmark
` x  `
$ printf '` x `' | cmark -t commonmark
`x`

If the inline code contains just spaces, then repeated parsing and rerendering makes the string get longer and longer.

HTML output is also a bit strange:

$ printf '` x `' | cmark -t html
<p><code>x</code></p>
$ printf '`  x `' | cmark -t html
<p><code> x</code></p>
@jgm
Copy link
Member

jgm commented Dec 19, 2019

There have been some changes to the spec around treatment of spaces at the beginning and end of inline code since the commonmark renderer was written; it needs some updating.

@jgm
Copy link
Member

jgm commented Dec 19, 2019

To understand the HTML output, see the spec.
"If the resulting string both begins and ends with a space character, but does not consist entirely of space characters, a single space character is removed from the front and back. This allows you to include code that begins or ends with backtick characters, which must be separated by whitespace from the opening or closing backtick strings."

@jgm jgm closed this as completed in 8a71de7 Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants