I'm trying to build an HTML element library (similar to Twitter Bootstrap) and I'd like to have a live version of the element next to the proper code markup for easy reference.
HERE'S THE LIVE PAGE FOR REFERENCE
I'm trying to use Prettify to display something like <button>Button</button>, but I'm having two problems:
- It seems to be adding random line breaks.
- It's only numbering the first line and then stopping.
Here's what I'm seeing when I view the page:

Question: What am I doing wrong here?
Here's the relevant HTML:
<html> <head> <title>Common HTML Library</title> <link type="text/css" rel="stylesheet" href="common.css" /> <link type="text/css" rel="stylesheet" href="prettify/prettify.css" /> <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <script src="script.js"></script> </head> <body> <div class="wrapper"> <!-- Button Section --> <h1>Buttons</h1> <p>Buttons should be used whenever something requires a clickable action which will result in a redirect, or dialog dismissal. Buttons appear in various states which are illustrated below.</p> <div class="live-example"> <div class="element"> <label for="defaultButton">Default Button</label> <button id="defaultButton">Button</button> </div> <div class="element"> <label for="primaryButton">Primary Button</label> <button id="primaryButton" class="primary">Primary</button> </div> <div class="element"> <label for="disabledButton">Disabled Button</label> <button id="disabledButton" disabled="disabled">Disabled</button> </div> </div> <div class="markup"> <button>Button</button> <button class="primary">Button</button> <button disabled="disabled">Button</button> </div> </div> <script type="text/javascript" src="prettify/prettify.js"></script> <script type="text/javascript">prettyPrint();</script> </body> </html> Here's the script.js file:
$(function() { $('.markup').wrapInner('<pre class="prettyprint linenums" />'); }); $(document).ready(function() { $('.prettyprint').html(function(i,h){ return h.replace(/[<>\"\'\t\n]/g, function(m) { return { '<' : '<', '>' : '>', "'" : ''', '"' : '"', '\t': ' ', '\n': '<br/>' // needed for IE }[m]}); }); prettyPrint(); }); It seems like something is happening when it replaces all of the <> with the Unicode equivalents...like it's ditching the line breaks and/or adding in new ones. What is going on here and how can I fix it?
