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

Codespan containing single space. #569

Closed
mity opened this issue Mar 26, 2019 · 5 comments
Closed

Codespan containing single space. #569

mity opened this issue Mar 26, 2019 · 5 comments
Milestone

Comments

@mity
Copy link

mity commented Mar 26, 2019

I noticed the recent changes to the specs regarding code spans and the new rules for eating just one initial and trailing spaces.

Currently, for single space between backticks, cmark renders an empty code span:

$ echo '` `' | ./build/src/cmark
<p><code></code></p>

But it would imho be better to render a code span with single space instead.

Rationale:

  1. If you want code span with one space, it is natural way how to write single space; and imho it is more important then easy way to create empty code span. (Who needs empty code span? It is likely rendered so that user cannot see anything anyway).
  2. The current specs wording does not indicate that single space can be eaten twice, by opener as well as closer marker. (And if it is intended, it imho should explicitly declare it.)

Either way, the specs should imho contain an example documenting how to render the given input.

@jgm jgm transferred this issue from commonmark/cmark Mar 26, 2019
@jgm
Copy link
Member

jgm commented Mar 26, 2019

I'm moving this to the spec repository, since the spec is vague here. I'm fairly convinced that we should make a change here. Whatever changes are made will of course have to be made in implementations.

The idea I like best is to add the phrase

   If the resulting string both begins *and* ends with a [space]
   character,
+ and does not consistent entirely of [space] characters

In cmark we're already traversing the whole string looking for newlines, so we can easily keep track of whether a nonspace character has been seen. This allows code spans with any number of spaces, which I think we want.

Drawbacks to making a change: You can no longer express "empty code span" in markdown. I don't like this kind of expressive limitation. And note that you can create a code span with one space (with current behavior) by putting three spaces between backticks.

@mity
Copy link
Author

mity commented Mar 26, 2019

- consistent
+ consist

@Crissov
Copy link
Contributor

Crissov commented Mar 26, 2019

You cannot express “empty emphasis span” or empty link in Commonmark either: foo **** bar <> baz. You can, however, express an empty link: foo []() bar, but not with references.

@mity
Copy link
Author

mity commented Mar 26, 2019

Drawbacks to making a change: You can no longer express "empty code span" in markdown. I don't like this kind of expressive limitation.

Then maybe it could be redefined so that a code span has

  1. an opener made by backtick sequence followed by single space and closer made by space followed by backtick sequence of the same length; or (if that is not possible)
  2. opener and closer both made by just backtick sequences of the same length.

Then one space would render as one space; and two spaces would render as empty code span. Currently empty code span can be rendered both by single space or two spaces which is too generous...

@jgm
Copy link
Member

jgm commented Mar 27, 2019 via email

@jgm jgm added this to the 0.29 milestone Apr 5, 2019
@jgm jgm closed this as completed in bcf7f72 Apr 5, 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

3 participants