2

So I want to build a XHTML 1.0 Strict based website. Using Notepad++ for syntax highlighting came as an idea to me. But when I tried to put the XML declaration (as stated in the spec, proper XHTML pages should use a XML declaration and be served as application/xhtml+xml) I can't get the entire document highlighted propperly. Here is the code I used for a basic page:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
    <head>
        <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
        <title>Page</title>
        <script type="application/javascript">
                alert("A perfectly valid xHTML page...");
        </script>
        <style type="text/css">
                #test {
                    text-align: center;
                }
        </style>
    </head>
    <body>
        <h1 id="test">TEST</h1>
    </body>
</html>

Paste this in Notepad++ and you'll see that it won't highlight the code between <script type="application/javascript"> and </script> (it renders its background white) if language is set to XML. If I set the language to HTML, then the script gets correctly highlighted but the XML declaration is not. What to do? How to make a hybrid language - combination of XML and HTML?

1 Answer 1

0

Notepad++ uses the extension of the file to decide on the Lexer (ie highlighter) to use. If you save your file as .xhtml then it should start highlighting properly. Actually you can save your file as .html because they both use the same Lexer.

If you look in the Notepad++ file langs.model.xml you'll see what I mean:

<Language name="html" ext="html htm shtml shtm xhtml hta" commentLine="" commentStart="&lt;!--" commentEnd="--&gt;">
    <Keywords name="instre1">!doctype a abbr accept accept-charset accesskey acronym action address align alink alt applet archive area article aside audio axis b background base basefont bdo bgcolor big blockquote body border br button canvas caption cellpadding cellspacing center char charoff charset checkbox checked cite class classid clear code codebase codetype col colgroup color cols colspan command  compact content contenteditable contextmenu coords data datafld dataformatas datalist datapagesize datasrc datetime dd declare defer del details dfn dir disabled div dl draggable dropzone dt em embed enctype event face fieldset figcaption figure file font footer for form frame frameborder frameset h1 h2 h3 h4 h5 h6 head header  height hgroup hidden hr href hreflang hspace html http-equiv i id iframe image img input ins isindex ismap kbd keygen label lang language leftmargin legend li link  longdesc map marginheight marginwidth mark marquee maxlength media menu meta meter method multiple name nav noframes nohref noresize noscript noshade nowrap object ol onabort onafterprint onbeforeonload onbeforeprint onblur oncanplay oncanplaythrough onchange onclick oncontextmenu ondblclick ondrag ondragend ondragenter ondragleave ondragover ondragstart ondrop ondurationchange ondurationchange onemptied onended onerror onfocus onformchange onforminput onhaschange oninput oninvalid onkeydown onkeypress onkeyup onload onloadeddata onloadedmetadata onloadstart onmessage onmousedown onmousemove onmouseout onmouseover onmouseup onmousewheel onoffline ononline onpagehide onpageshow onpause onplay onplaying onpopstate onprogress onratechange onreadystatechange onredo onreset onresize onscroll onseeked onseeking onselect onselect onstalled onstorage onsubmit onsubmit onsuspend ontimeupdate onundo onunload onunload onvolumechange onwaiting optgroup option output p param password placeholder pre profile progress prompt public q radio readonly rel reset rev rows rowspan rp rt ruby rules s samp scheme scope script  section select selected shape size small source span spellcheck src standby start strike strong style sub submit summary sup tabindex table target tbody td text textarea tfoot th thead time title topmargin tr tt type u ul usemap valign value valuetype var version video vlink vspace wbr width xml xmlns</Keywords>
</Language>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .