Quantcast
Channel: Delphi – The Wiert Corner – irregular stream of stuff
Viewing all articles
Browse latest Browse all 1440

reStructuredText Interpreted Text Roles

$
0
0

There is so much great stuff in reStructuredText, take for instance [WayBackreStructuredText Interpreted Text Roles where basically can create your own role (for instance :csharp: or :delphi: roles based on :code: for syntax-highlighted code blocks given the right syntax highlighters).

I got there via this great piece by[WayBackChris who answered [WayBackInline code highlighting in reStructuredText – Stack Overflow:

Having looked into this some more I stumbled upon the document reStructuredText Interpreted Text Roles. From this document:

Interpreted text uses backquotes (`) around the text. An explicit role marker may optionally appear before or after the text, delimited with colons. For example:

This is `interpreted text` using the default role.

This is :title:`interpreted text` using an explicit role.

It seems that there is a code role, so you can simply type

:code:`a = b + c`

to render an inline code block. To get syntax highlighting you can define a custom role. For example

.. role:: bash(code)
   :language: bash

which you can then use like so:

Here is some awesome bash code :bash:`a = b + c`.

Note, the document I link to makes no mention of the version of docutils to which it refers. The code role is not available in docutils 0.8.1 (which is the only version I have to test against).

–jeroen


Filed under: .NET, C#, Delphi, Development, Lightweight markup language, reStructuredText, Software Development

Viewing all articles
Browse latest Browse all 1440

Trending Articles