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

Allow using HTML in code blocks #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

imjoehaines
Copy link
Contributor

Using a noescape class (to mimic nohighlight from HLJS) you can specify that you don't want HTML tags in code blocks to be escaped.

This lets you add custom markup to a code block, which currently doesn't seem possible.

@imjoehaines
Copy link
Contributor Author

Hi @reimertz! Any chance this can get merged?

@reimertz
Copy link
Owner

Hey there, I am sorry for not replying to this earlier and it taking you to close it for me to respond.

Can you please elaborate what the issue is. If I am not misstaken, you should be able to have HTML in <code> blocks.

Just like I do here: https://reimertz.github.io/lagom/#12

I'm going to reopen this til we figured this out.

Again, sorry for the delay and thanks for taking the time to try and help out here!

@reimertz reimertz reopened this Apr 25, 2019
@imjoehaines
Copy link
Contributor Author

Hi, sorry for not being clear originally. This is to allow having your own markup in a code block, so you can do something like this:

<pre><code class="noescape">
    <span class="beep-boop">Content-Security-Policy</span>: connect-src 'none';
</code></pre>

Where the <span class="beep-boop">Content-Security-Policy</span> adds custom HTML in the middle of a code block. In this case it renders the text "Content-Security-Policy" in a span with the beep-boop class, rather than rendering the span as text and highlighting it as HTML

My use-case was a presentation on HTTP headers for security and HLJS didn't highlight it very nicely, which made it really hard to read. So I disabled the custom highlighting and applied this patch to let me add spans to highlight header names and values myself

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

Successfully merging this pull request may close these issues.

2 participants