How about this?
```
def role_fn(name, rawtext, text, lineno, inliner, options={}, content=[]):
# ref = docutils.nodes.reference(rawtext, text, internal=True,
refname=text, classes=['my-class-foo'])
ref = docutils.nodes.reference('', '', internal=True, refname=text,
classes=['my-class-foo'])
ref += docutils.nodes.literal(rawtext, text)
return [ref], []
```
--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa
On Sat, Apr 16, 2016 at 11:41 PM Andrea Cassioli <[email protected]>
wrote:
> Hi,
> thanks again! That works indeed....
>
>
> A last question: How do I force a literal node? I would like to make sure
> it is a literal regardless the CSS or the kind of output. In my
> understanding `nodes.reference` is a generic `TextElement`.
>
>
> On Saturday, 9 April 2016 16:29:39 UTC+2, Andrea Cassioli wrote:
>>
>> Hi,
>> I am struggling to find a way to do the following:
>>
>> - I would like to have a special role :myref: to link to specific
>> sections
>> - the new role should use a different layout, say show text in verbatim
>> - the new role should also have a class attribute so that it can be
>> customize using CSS
>>
>> What is a neat way to do this?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.