Hi Boris,

* You need docutils-0.9 or later because `code` role was introduced at
docutils-0.9.
* You need to place `role` directive before to use `:tex:`
* Sphinx need `highlight` class for syntax highlighting.

so::

   .. role:: tex(code)
      :language: latex
      :class: highlight

   Docutils uses LaTeX syntax for math directives and roles:
:tex:`\alpha =f(x)` prints :math:`\alpha = f(x)`.

Regards,
--
Takayuki SHIMIZUKAWA
Sphinx-Users.jp

2012/8/20 Boris Kheyfets <[email protected]>:
> I'm on Sphinx 1.1.3 and doutils 8.1 and Your code doesn't work:
>
>
> .. role:: tex(code)
>    :language: latex
>
> Docutils uses LaTeX syntax for math directives and roles: :tex:`\alpha =
> f(x)` prints :math:`\alpha = f(x)`.
>
> Gives:
>
> /home/boris/pst/wordy/edu/HotKeyPoetry/emacs.rst:10: ERROR: Unknown
> interpreted text role "code".
>
>
> .. role:: tex(code)
>    :language: latex
> /home/boris/pst/wordy/edu/HotKeyPoetry/emacs.rst:13: ERROR: Unknown
> interpreted text role "tex".
>
> Also I don't see the code role in the link You provide. But that's not that
> important.
>
> Can You see what is wrong?
>
>
> On Saturday, August 18, 2012 11:59:35 PM UTC+4, Guenter Milde wrote:
>>
>> On 2012-08-18, Boris Kheyfets wrote:
>>
>> > [-- Type: text/plain, Encoding:  --]
>>
>> > Is somehow possible to highlight a piece of text in line in a given
>> > language (with pygments)?
>>
>> > Something like this:
>>
>> > Some text :myLanguage:`from i to j; do` some more text.
>>
>> Yes, there is the :code: role for this since Docutils 0.8. In order to
>> highlight a language, you must define a custom role
>>
>> http://docutils.sourceforge.net/docs/ref/rst/directives.html#custom-interpreted-text-roles
>> based on "code".
>>
>> Example from the "standard.txt" test file:
>>
>>   For inline code snippets, there is the `code` role, which can be used
>>   directly (the code will not be parsed/tagged, as the language is not
>>   known) or as base for special code roles, e.g.,
>>
>>   .. role:: tex(code)
>>      :language: latex
>>
>>
>>   Docutils uses LaTeX syntax for math directives and roles:
>>   :tex:`\alpha = f(x)` prints :math:`\alpha = f(x)`.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-dev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sphinx-dev/-/aoSgothO948J.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sphinx-dev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to