UDL2 and perfect userDefindeLanguage for Jade

Art
2014-03-27
2014-03-28
  • Art

    Art - 2014-03-27

    Hi all,
    first of all I'd like to thank for such a great tool - UDL2, it's really awesome and helpful.

    Right now I'm trying to create more or less perfect UDL file for Jade templating language. There already exists one version, but it really simple and not perfect for more complicated work.

    Currently most of the work is done and the syntax highlighting is very improved, but I've stumbled on several issues:
    1) minor problem - folding ability, it's really hard to create folding rules for language that has no closing tags :)
    2) major problem - and I really hope you'd be able to help me - custom ID (#) and classes highlight and any words that go after whitespace should be black, this is what I have now:
    - http://oi58.tinypic.com/1zz5jy1.jpg

    And that's what I'm trying to achieve:
    - http://oi59.tinypic.com/2jcyh3.jpg

    Tell me please, is this possible? And if yes, then plz help me to do this.
    TIA.

     
  • Loreia2

    Loreia2 - 2014-03-27

    Hi Art,

    can you share pictures using some other service, links are blocked for me. You can attach them on sourceforge.

    BR,
    Loreia

     
  • Art

    Art - 2014-03-27

    Hi Loreia2,
    of course. Here it is:

     
    Last edit: Art 2014-03-27
  • Loreia2

    Loreia2 - 2014-03-27

    Hi Art,

    this is going to be a tough challenge for UDL :-)

    1. Folding is not possible without the closing keyword. Can you share a code sample here? We'll see if something can be done.

    2. "Words that must be black" problem should be resolved by defining Delimiter as:
      Start: title .nojs
      Close: ((EOL))

    Problem with this approach: starting keyword will have the same color as rest of the delimiter. One crazy way to work around it would be to define Keyword1 as:
    _ a b c ... x y z 1 2 ... 9 0 (and any other character that might be a word starter) and tick prefix option, now just allow nesting of Keyword1 within Delimiter1 and you will have different color for starting keyword.

    1. HTML tags that use use member methods, e.g.
      ul.social
      a.icon-youtube
      are really problematic. The only way to do this is to define
      Operator1: ul a (and all the others that have syntax TAG.method or TAG#method)
      Keyword1: . (and then tick prefix option)
      Keyword2: # (and then tick prefix option)

    Problem here is that UDL2.X have just one Operator1 type, and you are probably already using it for something else.

    Another problem is that every "ul" or "a" in text file will be highlighted. Hardly a desired behavior.

    Alternatively, you could define dot and hash (. #) as Operator1 type, and then define "ul a" as Keyword1 and "accessibility social icon-youtube" as keyword2 type.
    This will fail for "header" keyword though.

    BR,
    Loreia

     
  • Art

    Art - 2014-03-27

    Thank you for a quick response.
    I've tried the mentioned above methods, but still different issues are pop up, eg. inheriting of color by other words, etc.
    I've attached my Jade UDL file as requested.

    I have one idea, it's connected with usage of whitespace, eg: if ") " than the words that go after it will be black (or any other defined color).
    I attach screenshots to ease the understanding of issues and "whitespace" method.

     
  • Loreia2

    Loreia2 - 2014-03-28

    Hi Art,

    regarding picture 4:
    It is hard to keep text black because you can't wrap it in Delimiter. Best thing you could do is to define Delimiter like this:
    Open: )
    Close ((EOL))

    But I am not sure if this could have undesired consequences elsewhere.

    regarding picture 5:
    I am not sure what the problem is. Braces are defined as Operator1 style, so they shouldn't have any influence on text after it.

    regarding picture 3:
    If I understand correctly what you are trying to achieve, you should define another Delimiter4 like:
    Open: (
    Close: )
    And in it allow nesting of Keyword3 and Delimier1.
    In Delimiter3 allow nesting of Delimiter4.

    BR,
    Loreia

     
  • Art

    Art - 2014-03-28

    Hmmm, interesting...
    I will try to play with different given settings and will back later with report :)
    Thank you very much for help and ideas!

    PS. The idea with ability to set some settings using whitespace is still seems logical to me, as Jade itself is all about indents and whitespaces :)

     
  • Loreia2

    Loreia2 - 2014-03-28

    Hi

    I will try to play with different given settings and will back later with report :)

    It will probably take a while to get everything right. We can continue this exchange in next few days, We'll see if we can iron out remaining issues.

    The idea with ability to set some settings using whitespace is still seems logical to me, as Jade itself is all about indents and whitespaces :)

    Yes, but that goes against the very core of UDL. In UDL whitespace is only a delimiter of keyword. Nothing more. Language logic and structure is set by keywords, not by whitespaces.

    In UDL 3.0 there will be ability to control whitespace around delimiter start and end sequence. But that is the only place where whitespace can be part of UDL.

    Problem with your language is lack of explicit delimiter characters. For example, you define links by

    a(reference and access key here) display text goes here
    ~~~~~~~~~~~~~~~~~~~~~~~
    
    Here display text has default styler,  if you had something like
    

    a(reference and access key here) [display text goes here]
    ~~~~~~~~~~~~~~~~~~~~~~~

    then you could easily control two delimiter sequences () and [].
    UDL 3.0 will have ability to set which keyword groups get nested within default style, only then will you be able to exclude keywords from default text (and thus have display text painted in black color).

    BR,
    Loreia

     
    Last edit: Loreia2 2014-03-28

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

Sign up for the SourceForge newsletter:





No, thanks