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

Blank code span inconsistency #704

Closed
cabo opened this issue Feb 27, 2021 · 7 comments
Closed

Blank code span inconsistency #704

cabo opened this issue Feb 27, 2021 · 7 comments
Assignees

Comments

@cabo
Copy link
Contributor

cabo commented Feb 27, 2021

$ kramdown
` `

a ` `
^D
<p><code> </code></p>

<p>a ` `</p>
@gettalong
Copy link
Owner

gettalong commented Feb 27, 2021

From the syntax spec: "A single backtick surrounded by spaces is treated as literal backtick.". This is the reason why the second example shows only backticks.

As for the first example: No backtick is surrounded by whitespace because the first one is at the start of the line and the last one at the end. However, I think for consistency the first example should also be converted to <p>` `</p> - what do you think?

@cabo
Copy link
Contributor Author

cabo commented Feb 27, 2021

This was surprising to at least one user.
I believe the commonmark spec also allows code spans that are spaces only:
https://spec.commonmark.org/0.29/#code-spans

Anyway, picking up on the "single backtick" language, let's try a double backtick then:

$ kramdown
a `` ``
^D
<p>a <code></code></p>

This would do it for me, but the space goes away (a pair should go away, but then not for codespans that are solely spaces).

@gettalong
Copy link
Owner

gettalong commented Feb 27, 2021

If multiple backticks are used for code spans, a single space right after the opening backticks and right before the closing backticks are removed. So if you use:

``   ``

you will get

<p><code> </code></p>

This is always done, so one rule without special cases.

@cabo
Copy link
Contributor Author

cabo commented Feb 27, 2021

There weren't two spaces to be removed, so why are you removing the one that is there? :-)
The commonmark spec also makes an exception for spans that are entirely made up of spaces.

@gettalong
Copy link
Owner

The rule is just: If there is a space after the opening backticks, remove it. Then if there is one before the closing backticks, remove it. This is always done, so it doesn't depend on what exactly is inside the code span.

@gettalong
Copy link
Owner

I will update the parser so that the start of a line is also treated as whitespace. So for ` ` at the start of line the first backtick is then also surrounded by whitespace and therefore treated as text.

@gettalong
Copy link
Owner

The change mentioned in #704 (comment) will be in the next release.

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