Indent Rules for XML files

Syntax highlighting, code folding, brace matching, code indenting, and function list

Indent Rules for XML files

Postby giorgioperozzi » Wed Oct 25, 2006 8:34 am

Hi everyone, i'd like to set the AutoIndent for XML files (as made automatically by Internet Explorer, for instance),
i know i have to set "Indent String ="
and "Unindent String=" in wordfile.txt,
----------------------
Here my trials:
/Indent Strings = "<"name=*">"
/Unindent Strings = "</"name=*">"
----------------------

but i didn't manage to find the correct syntax in order to autoindent everytimes a tag occurs in file (opening or closing)
Could you give me some suggestion?
Thank you very much!
:D
User avatar
giorgioperozzi
Newbie
 
Posts: 4
Joined: Wed Apr 19, 2006 11:00 pm

Re: Indent Rules for XML files

Postby Mofi » Wed Oct 25, 2006 9:50 am

Regular expressions cannot be used for indent and unindent strings. Maybe following is enough - have not tested it:

/Indent Strings = "">"
/Unindent Strings = "</"
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Indent Rules for XML files

Postby giorgioperozzi » Wed Oct 25, 2006 1:48 pm

Thank for reply, i have already made that trial, but it doesn't work!
:roll:
User avatar
giorgioperozzi
Newbie
 
Posts: 4
Joined: Wed Apr 19, 2006 11:00 pm

Re: Indent Rules for XML files

Postby Mofi » Thu Oct 26, 2006 1:18 pm

A small question: Are the tag names in double quotes in your XML files highlighted as strings?

Yes, then that's one of the reasons why the indent string does not work because the " is part of a string and indent strings are ignored in strings. Make following changes:

  1. In the language definition line insert or modify the string character definition to String Chars = '. With this modification the simple indent string should work (not tested in lack of an example).

  2. To highlight double quoted strings with the color of strings or a different color add following line above /C1"..":

    /Marker Characters = """"

    And create a color group for the marker characters like:

    /C8"Double quoted strings"
    ""


    Now you can specify the color for double quoted strings too.
But all these changes will not help for the indent string "">".

Reason: The double quote character is used in the wordfile as indent string delimiter. So UE reads "" and >" and ignores that because invalid syntax for indent strings.

I don't know if there is an escape character which can be used to tell UE that the following " character should be part of the indent string and is not a indent string delimiter. Ask IDM support by email.

But I think, there is none. If you always edit the same sort of XML files and there are not too many different name= and </name> tag pairs you can specify all that strings as indent and unindent strings.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Syntax Highlighting