Sublime Forum

ReST syntax and theme contribution

#1

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:

.. 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 :smile:

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

Comments welcome.

Chh

0 Likes

Restructured Text - Theme Support
#2

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: github.com/jhaubrich/Jesse-s-Sublime-Mods

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

#3

Hey Jesse,

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

Left: my code, Right: your modification.


0 Likes