Sublime Forum

Syntax Highlighting for URLs

#1

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.

The syntax definition in Coda 2 is:

[code]
(?<= \t])(?i)(?:href|src) \t]= \t]"
"

				<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>

[/code]

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

0 Likes

#2

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.

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

0 Likes

#3

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).

0 Likes

#4

Thank you skuroda for that hint.

The urls have there own scope. So I will try out that plugin.

0 Likes

#5

[quote=“TeeGee”]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.

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[/quote]

What changes have you made to the “tag-id-attribute”?

Thanks!

0 Likes