-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Leave the content of <code>
and related HTML elements untouched by CommonMark parser
#711
Comments
Hmm, if you want code, use markdown code: backticks. |
I could have used the backticks, but I needed to handle cases where I can add my custom HTML annotations to the inline code blocks. Here's a watered down example: In Nim, <code class="inline-src language-nim" data-lang="nim">echo "hello"</code> will print
_hello_. Another usecase is to do syntax highlighting using classes in code tags.. here's a screenshot of what I mean (note the inline colored code in there) Right now, I am doing this by bypassing a commonmark parser. |
Can you point to a usecase where people would want a markdown parser to render stuff inside |
To add links to code for example |
This is the way Markdown has traditionally done it, starting with Markdown.pl. https://babelmark.github.io/?text=%3Ccode%3E%0A**a**%0A%3C%2Fcode%3E%0A |
@wooorm I don't follow.. the code element is for inline code. The current CommonMark behavior is inconsistent between block code ( |
I understand.. but may be it's our opportunity to fix that? I cannot find anyway in Markdown that I can write inline code with HTML attributes like so
|
A strong degree of compatibility with existing implementations was a design goal. I do see why this prevents you from doing what you want to do here. It's not really a problem in pandoc, for example, where you can just do
or use the raw attribute
But there does seem to be an expressive gap here in core commonmark. |
With the current state, you can mark certain parts of the code as important, or link them. With your proposal, you can’t. |
@jgm Unfortunately I am not using pandoc. I am using the Go Commonmark parser called Goldmark through Hugo (static site generator).
Note that will will affect only inline code. You cannot do those anyways in block code blocks or Again, an example of this in wild will be useful. |
Bringing complete consistency is impossible: HTML in markdown is a black box. It “sniffs” things that look like XML and switches to a different state based on it starting with Some examples: |
In HTML, |
Hi there, we just noticed our Graphviz docs (hugo/goldmark-based) have smart quotes, breaking copy/paste (Graphviz docs issue), where we're using
Shows these smart quotes, unintentionally: We seem to be stuck between two bad places: we seem to be relying on some markdown processing inside our code tag (to generate the |
@mhansen you both want and don't want markdown processing inside the code span.
Or even better
|
Thanks for the workaround. We'll need to remove left & right padding and the code-block rounded corners from our code blocks so they don't have extra padding and rounded corners, like the bottom here: We can probably get away without the padding and rounded corners, though it won't look as nice, we might end up doing that: FWIW, I'd be very happy to give up all markdown parsing in |
Hello,
Recently I discovered that CommonMark allows Markdown parsing within
<code>
blocks!So if user had something like
<code>**bold**</code>
in their markdown content (which is analogous to Markdown`**bold**`
), the CommonMark parser would parse those asterisks in there.This can be reproduced at least with this CommonMark dingus
Can the spec be updated so that the content inside
<code>
(and also<kbd>
,<samp>
and<var>
) also be treated verbatim like that done for the<pre>
element?<code> element
Now, if that short fragment happens to have Markdown markup characters, we don't want a markdown parser to render those as Markdown!
<kbd> element
The textual user input on the keyboard can contain asterisks, underscores and square-brackets too. We wouldn't want a Markdown parser to interpret those!
<samp> element
What if the computer program is outputting Markdown text.. we want this element to show exactly what the computer program's output was; we won't want a Markdown parser to corrupt the sample of the output which the user is trying to preserve in a
<samp>
element.<var> element
Mathematical expressions easily contain asterisks. We don't want the Markdown parsers to touch these elements either!
/cc: @jmooring
The text was updated successfully, but these errors were encountered: