Home Download Buy Blog Forum Support

Syntax highlighting and themes for markup language

Syntax highlighting and themes for markup language

Postby alexvn on Thu Jun 06, 2013 7:22 pm

Hello,

I'm trying to build a syntax highlighting for markup language but found it quite tricky. I'm know the regular expressions, installed the AAAPackageDev package, successfully created a very trivial highlighting file but then completely stuck on the scopes and how to highlight/define them.

How it looks now:

Code: Select all
{
  "name": "IVY Markup",
  "scopeName": "text.ivy_markup",
  "fileTypes": [ "ivy" ],
  "patterns": [
    {
      "match" : "^h\\d. .*",
      "name" : "keyword.ivy_markup",
      "comment" : "Heading"
    },
    {
      "match" : "\\*\\w(.*\\w)?\\*",
      "name" : "markup.bold.ivy_markup",
      "comment" : "Effects: strong"
    },
    {
      "match" : "\\_[\\w ]+\\_",
      "name" : "markup.italic.ivy_markup",
      "comment" : "Effects: emphasis"
    },
    {
      "begin" : "^h\\d. .*",
      "end" : "^h\\d. .*"
    }
  ],
  "uuid": "7d7e0c90-9df4-11e2-9e96-0800200c9a66"
}


And it looks like it works well, but it does not apply any formatting to the text that intended to be bold or italic, e.g. "test *bold* _italic_".

How this should be specified? Thanks!
alexvn
 
Posts: 2
Joined: Thu Jun 06, 2013 7:14 pm

Re: Syntax highlighting and themes for markup language

Postby FichteFoll on Thu Jun 06, 2013 9:28 pm

Syntax definitions define scopes and color schemes make them appear in fancy ways, depending on their scope selector. So, what you need is either a color scheme that defines scopes like these:

Code: Select all

      <dict>
         <key>name</key>
         <string>Markup: Bold</string>
         <key>scope</key>
         <string>markup.bold</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string>bold</string>
         </dict>
      </dict>
      <dict>
         <key>name</key>
         <string>Markup: Italic</string>
         <key>scope</key>
         <string>markup.italic</string>
         <key>settings</key>
         <dict>
            <key>fontStyle</key>
            <string>italic</string>
         </dict>
      </dict>


or you need to edit your current scheme to contain them.
FichteFoll
 
Posts: 402
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Syntax highlighting and themes for markup language

Postby alexvn on Fri Jun 07, 2013 12:04 pm

Ok then. Assuming that I use "Mac Classic" color scheme, is there any way to correctly extend it (not by modifying the main theme file) with rendering rules for the new scopes (defined in the syntax definition)?
alexvn
 
Posts: 2
Joined: Thu Jun 06, 2013 7:14 pm

Re: Syntax highlighting and themes for markup language

Postby FichteFoll on Fri Jun 07, 2013 12:56 pm

No, you have to modify it.

Copy it from the "Theme - Default" package to "User" and edit it there, it won't be overridden like this by future updates. Then just change the color scheme setting to point to your modified version.
FichteFoll
 
Posts: 402
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 9 guests