0

I am trying to use prettify like this:

<code class="prettyprint lang-html">
    <link rel="stylesheet" href="themes/myPlug/styles.css?v=1.0">
    <script src="js/myPlug.js"></script>
</code>

But no text is output on my page, do I have to manually convert every bracket, ie.

< to &lt;

and

> to &gt;

in order to use prettify with HTML code?

Matt Welander
  • 8,234
  • 24
  • 88
  • 138

2 Answers2

3

Yes you need to convert < to &lt; and > to &gt; manually. Also to note that prettify works with HTML but for the brackets you have to change them manually.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

Basicially you just have to replace the opening tags but I think it is easier just to use a formatting service such as freeformatter.

The same problem occurred for me using SyntaxHighlighter. Under Installation it says you have to replace them.

PROBLEMS: Major issue with this method is that all right angle brackets must be HTML escaped, eg all < must be replaced with &lt; This will ensure correct rendering.

SyntaxHighlighter offers another method for highlighting your code by just including everything within a script tag using a CDATA block.

The benefit of this method is ability to place virtually anything inside the CDATA without having to escape anything*, so this allows for a straight ‘cut and paste’ experience from your favorite text editor.

oshell
  • 8,923
  • 1
  • 29
  • 47