-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add processing of inline code in Markdown #38
Comments
I'm interested in this too. Haven't found a way to process inline code blocks yet. |
@lautarodragan, I think it is possible to automate only with a custom instance of I use that function: |
Thanks @sashaqred !! That worked 😄 |
To build on @sashaqred's example in case anyone else runs into it, markdownit's default inline rule escapes the HTML, so if you don't also do so you may run into issues when using things like // setup
const markdownIt = require("markdown-it");
const mdSetup = markdownIt({ html: true})
// The important part below. Replace mdSetup with your instance of markdownit,
// and replace attributes and classes as needed.
mdSetup.renderer.rules.code_inline = (tokens, idx, { langPrefix = "" }) => {
const token = tokens[idx];
return `<code class="${langPrefix}">${mdSetup.utils.escapeHtml(token.content)}</code>`;
}; |
@markmichon, good catch! Recently I've faced such an issue. Your comment saved some time for me 😅 |
I used markdown-it with markdown-it-highlightjs with this style. It looks a bit weird because it will guess the language when inline but you can just turn off |
Hi,
Recently I've tried writing some code with 11ty in markdown and faced with something unexpectable. With block code, everything works fine. But inline code is not.
This code
will be transformed into this:
Seems like inline code isn't processed at all. On block code result there are bunch of extra classes but on inline none of them.
As temporal fix I'm using HTML in markdown (
<code class="language-">Some inline code with custom wrap</code>
).Is this a bug or my misconfiguration?
The text was updated successfully, but these errors were encountered: