script highlight in xml

deCarnac
2010-06-13
2012-11-13
  • deCarnac

    deCarnac - 2010-06-13

    When I edit an HTML file with embedded Javascript, the script content is highlighted as Javascript.

    However, when I edit an XML file with embedded Javascript, the script isn't recognised. An example:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <head>
    <title>Example</title>
    </head>
    <body onload="init();">
    <script type="text/javascript"><![CDATA[
    var laps = 7;
    function init(){
    for(var i=0; i < laps; i++){
    // various code here
    }
    }
    ]]></script>
    <svg:svg id="example_svg" width="600" height="600">
    <! - various elements here ->
    </svg:svg>
    </body>
    </html>

    I would like Notepad++ to recognise the type declaration in the script tag, and highlight its contents accordingly. Are there any settings I have missed that would make this happen, or is this a feature that is to be added in the future?

    The example above may not require it as much, but highlighting helps a lot when code looks like this:

    obj.setAttributeNS(null, "transform", "rotate("+rot_v+" "+gl_rot_c+" "+gl_rot_c+") translate("+(gl_rot_c+radius_cc)+","+gl_rot_c+")");

    I currently use Notepad++ 5.6.8.

     
  • deCarnac

    deCarnac - 2010-06-17

    I posted this in the Open Discussion, because I'm not really sure what part of the forum the question belongs to.

    Is the described behavior the result of a:
    A) user error (i.e. me not using the right setting or plugin),
    B) bug, or
    C) feature not yet implemented?

     
  • Dave Brotherstone

    Change the language to HTML in the language menu.  Notepad++ only looks at file extension to identify the file, you can change which extensions are associated to which languages in the "Style Configurator".

     
  • deCarnac

    deCarnac - 2010-06-17

    Thanks davegb3! I selected language: HTML and the script was then correctly highlighted.

    However, while set as HTML language, the SVG part was no longer highlighted. It seems that the root of my problem is that I'm using multiple namespaces in the same file, and I can't get both recognized simultaneously. But I guess I can switch back and forth manually while editing.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks