Using Google Prettify to display HTML
问题 for Google Prettify to display HTML code sample properly, you should replace all the < with < and all the > with > . How do you automate that process using JavaScript only ? 回答1: If you put your code inside an <xmp> element, you don't need to escape HTML special characters as shown in the tests <h1>HTML using XMP</h1> <xmp class="prettyprint" id="htmlXmp" ><html> <head> <title>Fibonacci number</title> </head> <body> <noscript> <dl> <dt>Fibonacci numbers</dt> <dd>1</dd> <dd>1</dd> <dd>2</dd>