Test Code Examples

Here’s a code example with <pre> tags around it. There should be extra spacing between the query and the result than the two lines of the query.

SELECT 'Spiders are deadly'
FROM DUAL;

Spiders are deadly

And here is the entire HTML fragment from above

<p>Here’s a code example with <pre> tags around it. There should be extra spacing between the query and the result than the two lines of the query.</p><pre>SELECT ‘Spiders are deadly'<br />FROM DUAL;<br /><br />Spiders are deadly</pre><p><br /> </p><p />

And here’s a try without using line breaks at all, but having them in the text itself

SELECT 'Spiders are deadly'
FROM DUAL;

Spiders are deadly

Which I now realise is the way to go. It’ll just mean me switching back and forwards between wysiwyg editing and the HTML window. Not too hard but I won’t be fixing up all of the old blogs

6 comments

  1. Doug,

    You could hack this so that you can enter the html “incorrectly” [i.e. using tags inside the tag] and then use a piece of javascript to fix it up on page load. Off the top of my head, something along the lines of

    //find all pre tags in the document
    var pretags = document.getElementsByTagName(“PRE”);

    //replace any br tag inside it with a newline
    for(i=0; i

  2. Bugger. Javascript seems to break the comments! That should have said “using &lt;BR/&gt; tags inside the &lt;pre&gt; tag” and the javascript should have been

    var pretags = document.getElementsByTagName(“PRE”);

    for(i=0; i&lt;pretags.length; i++){
    pretags[i].innerHTML = pretags[i].innerHTML.replace(‘&lt;br/&gt;’,’\n’);
    }

  3. I notice in your stylesheet it says

    #content pre {
    font-family: Lucida Console, fixed;

    “fixed” isn’t a font family – it should be “monospace”. Currently I don’t see a monospace font on Apple Mac because I don’t have Lucida Console.

Leave a comment

Your email address will not be published. Required fields are marked *