Home Download Buy Blog Forum Support

ReST syntax and theme contribution

ReST syntax and theme contribution

Postby chh on Wed Feb 29, 2012 10:52 am

Hi fellows,

I want to contribute two additions for ReST support. However, I don't know how to extend existing syntax definitions or themes in-place (can anybody here tell me how to do this?), so I had to create duplicate versions of the shipped files with my extensions added:

(1) reStructuredTextExtended.tmLanguage, which is an extended version of the shipped restructuredText.tmLanguage file.
- Removed the meta.paragraph.restructuredtext definition, so that normal text will be colored just like all other standard text as defined in the currently used color theme.
- Added definitions for the ReST directives .. sourcecode:: bash, .. sourcecode:: console, .. sourcecode:: guess and .. sourcecode:: python
- Added definitions for the ReST directives .. NOTE::, .. ATTENTION:: and .. WARNING::
- Corrected some regex flaws.

(2) TwilightExtended.tmTheme, which is an extended version of the shipped Twilight.tmTheme (modified with strong influences from Zenburn), including some basic ReST definitions I found elsewhere, as well as the additions described above.


Please consider these files as work-in-progress, I just hacked them together until it worked. The UUIDs were generated with Python's uuid module (see comments in files) because I found no "official" way to do this. I also had to patch the shipped Shell-Unix-Generic.tmLanguage file a bit (i.e. the case clause was not closed properly). I attached it, too.

There are still some constructs that don't work. Especially I failed at building a definition that would allow the console directive (see above) to be properly highlighted. Note that this directive is used in the Sphinx Documentation Generator. Here is an example:

Code: Select all
.. sourcecode:: console
   
   $ cat /etc/lsb-release
   DISTRIB_ID=Ubuntu
   DISTRIB_RELEASE=11.10
   DISTRIB_CODENAME=oneiric
   DISTRIB_DESCRIPTION="Ubuntu 11.10"


I would like to highlight the command following the prompt character "$" just like other bash code, but the lines without the prompt sign should be treated as a different scope (i.e. normal text or something else). You can still find fragments of my efforts in the provided files, I'm too lazy right now to clean them up :)

Since a cannot attach files here, I uploaded them by myself:
http://www.christianhinrichs.de/projekte/sublime/

Image

Comments welcome.

Chh
chh
 
Posts: 3
Joined: Wed Feb 29, 2012 8:52 am

Re: ReST syntax and theme contribution

Postby jackaesop on Sat Mar 03, 2012 3:14 am

Thanks! This is quite good. I started working on my own and just replaced most of it with yours. I've added lists and preformated blocks to what you've already done.

I've posted mine on github: https://github.com/jhaubrich/Jesse-s-Sublime-Mods

<!-- Lists: reStructuredText.tmLanguage (line 18) -->
<dict>
<key>name</key>
<string>markup.list.restructuredtext</string>
<key>match</key>
<string>(^\s*[\*\-\+]\s+)|(^\s*[0-9a-zA-Z][\.\)]\s+)|(^\s*\([0-9a-zA-Z]\)\s+)</string>
</dict>


<!-- Lists: Monokai.thTheme (line 555) -->
<dict>
<key>name</key>
<string>Markup: List</string>
<key>scope</key>
<string>markup.list</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#AE81FF</string>
</dict>
</dict>
jackaesop
 
Posts: 2
Joined: Thu Mar 01, 2012 3:08 am

Re: ReST syntax and theme contribution

Postby chh on Mon Mar 05, 2012 11:13 am

Hey Jesse,

thanks for the list rule. Your preformatted block modification however seems to break something:

Left: my code, Right: your modification.
ReST-highlight1.png
ReST-highlight1.png (13.77 KiB) Viewed 1805 times
chh
 
Posts: 3
Joined: Wed Feb 29, 2012 8:52 am


Return to Technical Support

Who is online

Users browsing this forum: Majestic-12 [Bot], Yahoo [Bot] and 28 guests