highlightjs with html code


How do I put my HTML code so that highlight.js prettify it ?

I tried

        <!-- HTML Prettify -->
            <pre class="pre-code-ception"><code> haha </code></pre>

I did put at the end of my file :

<script type="text/javascript">

But everything is shown as plain HTML.


Oh, I think I understand the problem. You need to escape the HTML within the <code> element, otherwise it will be interpreted as HTML instead of text (you want the HTML displayed literally, not interpreted as part of the webpage structure).

Change every < to &lt; and > to &gt;, as well as any other special HTML characters in your code sample. (If you’re generating the page on the fly, most languages have a utility function to escape the HTML for you.)

Answered By – Cameron

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.