views:

259

answers:

2

i tried to use Syntax Highlighter in a XHTML/CSS Template. i noticed if i use the .xhtml extension the Syntax Highlighter fails. if i rename the extension to .html it works.

so the question is: - Syntax Highlighter does not work with XHTML? - whats the difference between .xhtml vs .htm/html? if i still have the same code? xml declaration etc (for xhtml)?

i tried 1.5.1 and 2 (http://alexgorbatchev.com/wiki/SyntaxHighlighter) when i rename extension to html it will work

Syntax Highlighter 2.0 code

$(function() { SyntaxHighlighter.all(); });

<pre class="brush:xhtml"><h1 class="bottom">This is a normal H1</h1> <h1 class="tag">This is a H1 with a class "tag"</h1></pre>

+1  A: 

There's no difference in particular between the extensions in terms of syntax highlighting; most likely the issue is that the syntax highlighter in question simply isn't configured to recognized .xhtml as an XHTML document.

If you don't have the opportunity to futz about with the source of your particular installation; I'd recommend simply passing .html or .xml as the extension; it should yield the same result.

Williham Totland
i am starting to think there maybe some differences between .html/htm vs .xhtml ... in .xhtml i can do <div class="clear" /> in html i need to do <div class="clear"></div>
iceangel89
Then use the XML syntax highlighter, unless the HTML highlighter does something really screwy or highlights invalid attributes etc. differently.
Williham Totland
hmm when i use .html, the highlighting works. w3c xhtml 1.0 strict also validates. does this mean its just a extension bug? or the validator do not check javascript output xhtml?
iceangel89
I'd say it's probably an extension bug; as in; the HTML highlighting actually works for XHTML; but the extension (or possibly your IDE) doesn't recognize .xhtml files because it's not properly configured.
Williham Totland
iceangel89
A: 

changing the extension to .html does the trick, i guess somehow Syntax highlighter does not recognize/work in .xhtml extension or something.

iceangel89