Home Download Buy Blog Forum Support

Syntax Highlighting for URLs

Syntax Highlighting for URLs

Postby TeeGee on Fri Mar 29, 2013 11:47 am

Hello,

in Coda 2 links can be highlighted in other colors or underlined via themes.
I like this feature and want this for Sublime Text 2 too.

Image

The syntax definition in Coda 2 is:
Code: Select all
               <state id="Links" type="url" useforautocomplete="no" scope="meta.link">
               <begin><regex>(?&lt;=[ \t])(?i)(?:href|src)[ \t]*=[ \t]*"</regex></begin>
               <end><regex>"</regex></end>
               
               <state id="Javascript in Links" usesymbolsfrommode="JavaScript" useautocompletefrommode="JavaScript" scope="meta.block.js">
                  <begin><regex>\A[ \t]*(?i)javascript:</regex></begin>
                  <end><regex>(?'unwindend'")</regex></end>
                  <import mode="JavaScript" keywords-only="yes"/>
                      <import state="JavaScript Container"/>
               </state>
               
               <keywords id="Link Attribute" useforautocomplete="no" scope="markup.tag.attribute.name">
                  <regex>\A(\w+)[ \t]*=</regex>
               </keywords>
               
               <keywords id="Link Quotes" useforautocomplete="no" scope="markup.tag.attribute.value.string">
                  <regex>(")</regex>
               </keywords>
               
               <keywords id="Link Equals" useforautocomplete="no" scope="markup.tag">
                  <regex>\A(?i)\w+([ \t]*=[ \t]*)</regex>
               </keywords>
               
            </state>


I tried to convert and integrate this into HTML.tmLanguage but with no success.
Please can someone do this for me?

Sorry for my bad english.

Thomas
TeeGee
 
Posts: 3
Joined: Fri Mar 29, 2013 11:29 am

Re: Syntax Highlighting for URLs

Postby TeeGee on Sun Mar 31, 2013 8:20 pm

Hello,

I solved the "problem" by own now.
Examining "HTML.tmLanguage" helped me at last.
I copied the definition of "tag-id-attribute" and modified it for href and src.

Image

At line 22, 27 and 28 you can see the link in blue color and italic style. Underline is not supported by Sublime Text 2 at all.

Now I am happy with Sublime Text.

Thomas
TeeGee
 
Posts: 3
Joined: Fri Mar 29, 2013 11:29 am

Re: Syntax Highlighting for URLs

Postby skuroda on Sun Mar 31, 2013 8:28 pm

TeeGee wrote:At line 22, 27 and 28 you can see the link in blue color and italic style. Underline is not supported by Sublime Text 2 at all.


If you have given the urls there own scope, which I'm guessing you did, you can use the PersistentRegexHighlght plugin to underline. As an example, please see the following stack overflow (link).
skuroda
 
Posts: 676
Joined: Fri Oct 05, 2012 8:11 am

Re: Syntax Highlighting for URLs

Postby TeeGee on Sun Mar 31, 2013 9:34 pm

Thank you skuroda for that hint.

The urls have there own scope. So I will try out that plugin.
TeeGee
 
Posts: 3
Joined: Fri Mar 29, 2013 11:29 am


Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 9 guests