Help on "regular expressions" in syntax definition files

Started by cichlasoma, May 04, 2010, 04:10:44 PM

Previous topic - Next topic

cichlasoma

Hi.

Is there any help file on how to use regular expressions in HippoEDIT's syntax defining files?

How can I define a style for blocks beginning with "fnx." where x is any integer e.g.?
And isn't there any keyword similar to "noneof" used in

         <Block open="0x">
           <Close noneof="0-9A-Fa-f"/>
         </Block>

e.g. but meaning "any of"?

And how can the "noneof" keyword be used to specify the opening, not closing character sequence of a block?

And a question more, just to be sure: isn't there a file defining syntax (highlighting) for markdown or textile?

alex

Hi cichlasoma,

welcome on forum.

Hm.. I thought that I have already described this in FAQ, but found that not. So I have extended syntax definition explanation.
You will find there answers to your questions in Blocks section.

Hippoedit does not support regular expressions in syntax definitions yet, only in labels. And only fixed open tags are supported.
So, the only way I see to achieve what you what you want will be to define all variations. Or define block startting with fn and close with
<Close noneof="0-9"/>.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

cichlasoma

Hi Alex!
Thank you very much for your answer and for the FAQ extension!

Quote from: alex on May 04, 2010, 06:39:00 PM
Or define block startting with fn and close with
<Close noneof="0-9"/>.

As for your suggestion quoted, I don't get it - could it really work as a definition of a block starting with "fn[integer]." (note the period) and ending with newline e.g. (which is how footnotes in textile are defined)?

Kind regards,
c.

alex

... :/ No. Will not work.
You want to have dynamic start tag, which is not supported yet..
Even for close tag it is not possible, because regular expressions are not supported.
I am planning to add support of the regular expressions for highlighting, but do not know when.
Main problem with them is in times slower parsing performance and effort of integrating in current infrastructure.

The only one ugly way I can suggest here is to define explicit style for every footnote, as:
<Block open="fn0." close="\n"/>
<Block open="fn1." close="\n"/>
<Block open="fn2." close="\n"/>
etc...
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

cichlasoma

#4
alex: Thank you!

cichlasoma

I'd have two questions more:

1) Is there a way how to define a block closing with two EOLs ( <Block open="fn1" close="\n\n"/> does not work.)

2) How to define alternative closing strings of a block?
Whereas

      <Style id="heading1" name="Heading1" text="1" bold="1" italic="0" underline="1" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open="h1. " close="\n"/>
          <Block open="h1{" close="\n"/>
        </Blocks>
      </Style>

does work for alternative opening strings,

      <Style id="link" name="Link" text="1" bold="0" italic="1" underline="1" clr="#FF99CC" bkclr="#FFFFFFFF">
        <Blocks>
          <Block open="aa" close="\n"/>
          <Block open="aa" close=" "/>
        </Blocks>
      </Style>-->

does not work for closing ones.

alex

1) No. There is not such way. \n is not a real check for \n in text (you can have different line break styles in same document), but just indicator to engine that parsing is till end of the line. HippoEDIT does here not a stream text processing, but by line processing.

2) Yes. You can define alternative close tags like this:
<Block open="aaa" close="bbb">
    <Close text="ddd"/>
    <Close text="\n"/>
    <Close anyof="db"/>
</Block>


but I think, by design, your way should also work...
If not, I can assume it as a bug, and will fix in next 1.49 beta.

Can you paste here some example of the text you want to highlight? Than maybe I will suggest how to process in a better way, using what is possible in HE now and what is planned.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

cichlasoma

#7
alex: Thanks!

Yes, I it seems to me to be a bug as well... Sometimes, HE takes the first ending to be the valid one, sometimes the second one, I cannot figure out what's going on.
Another syntax definition files related bug I believe to have found is that following three styles are rendered in the same color for me. When I choose any other colors than shades of green, it works, but with kinds of green it doesn't.

     <Style id="bulletedListLevel1" name="bulletedListLevel1" text="1" bold="1" italic="0" underline="0" clr="#339900" bkclr="#FFFFFFFF">
       <Blocks>
         <Block open="* " close="\n"/>
       </Blocks>
     </Style>

     <Style id="bulletedListLevel2" name="BulletedListLevel2" text="1" bold="1" italic="0" underline="0" clr="#66CC33" bkclr="#FFFFFFFF">
       <Blocks>
         <Block open="** " close="\n"/>
       </Blocks>
     </Style>

     <Style id="bulletedListLevel3" name="bulletedListLevel3" text="1" bold="1" italic="0" underline="0" clr="#99FF66" bkclr="#FFFFFFFF">
       <Blocks>
         <Block open="*** " close="\n"/>
       </Blocks>
     </Style>
     
     
     As for defining alternative closings in the way you suggest - it works, thanks.
     (I used it for the following:
     
           <Style id="link" name="Link" text="1" bold="0" italic="1" underline="1" clr="#FF99CC" bkclr="#FFFFFFFF">
             <Blocks>
               <Block open="&quot;:http://" close="\n">
                 <Close text=" "/>
               </Block>
             </Blocks>
           </Style>
     
      which is not perfect way of highlighting links in textile, but it works somehow.
      (The syntax is
      "linktext":http://...   )

Kind regards,
c.

alex

Ok, I will check with alternative closing.

About problem with colors, check user file for your schema (it created automatically), it can also contain colors for your styles (when they changed through UI) and have priority over settings in spec file.
Also try to use palette colors if possible, otherwise it will be not possible to use your schema with non default color schemes.

About link highlighting: check def_spec.file, you can control where (in which container/style) allowed, and maybe reuse. You can also import definitions to your style.

HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

cichlasoma

alex: As for "green issue", it happens without any user file as well. (And if it were caused by a user file, other colors in the styles definitions would not be reflected as well, IMHO. But if I set other colors than shades of green, it works. (Really strange...)

As for "palette colors" and "non default color schemes", couldn't you be more explicit or give me a link to some explanatory docs? (I have no idea what you are talking about... :-( )

alex

Hm... I never got report like this, so i think there is some error in your schema file :) When I wrote user file, I mean xxx_user.xml, where  xxx is name of your syntax. It created always, if you change settings for syntax from UI, and has copy of all default settings.
If you are sure that it not like this, send me your file to supportbox hippoedit com, I will check.

Normally (in default syntax schemes), colors are defined not explicitly (as #FFAAFF) but with referring to some named color from active palette:
<Style id="search_result" name="Search Result" bold="2" italic="2" underline="2" clr="#FFFFFFFF" bkclr="Search Result" overview="1"/>
Here Search Result is named color, from current palette. Check \data\colors\color_default.xml for complete list. All color schemes (palettes) should have same named color set, and in this case, when you switch color scheme in HippoEDIT UI, you will not get situation when you have black background and black text.

HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

cichlasoma

#11
Quote from: alex on May 05, 2010, 04:15:05 PM
Hm... I never got report like this, so i think there is some error in your schema file :)

If I paste the lines I posted into the python_spec.xml, thus adding three new styles to Python's syntax, it behaves just like in my own definition file (All the sthree styles are disploeyed in the same colour (although in Syntax settings/Fonts and colors, different colors are shown for them, BTW)). Therefore, it doesn't seem to be a problem of my file... I am going to send you the modified python_spec.xml to avoid any confusion.

QuoteWhen I wrote user file, I mean xxx_user.xml, where  xxx is name of your syntax. It created always, if you change settings for syntax from UI, and has copy of all default settings.
If you are sure that it not like this, send me your file to supportbox hippoedit com, I will check."

(I know what you meant by "user file" - it happens also when I remove the xxx_user.xml file.)

QuoteNormally (in default syntax schemes), colors are defined not explicitly (as #FFAAFF) but with referring to some named color from active palette:
<Style id="search_result" name="Search Result" bold="2" italic="2" underline="2" clr="#FFFFFFFF" bkclr="Search Result" overview="1"/>
Here Search Result is named color, from current palette. Check \data\colors\color_default.xml for complete list. All color schemes (palettes) should have same named color set, and in this case, when you switch color scheme in HippoEDIT UI, you will not get situation when you have black background and black text.

Thank you for the explanation. :-)

alex

Ok, I have tried and know the reason.

The contrast between color you have selected for text is not enough for white (default) background.
The ration should be at lease 5:1 default (UI standards). Otherwise editor will optimize it (what has happened).
To see your explicit colors, go to Tools->Color Schemes->Contrast and set it to Do not Change.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

cichlasoma


cichlasoma

(alex: BTW, I'd find it really nice if a user were reminded by HE that some color was "blocked" when it happens...)