-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RST reader and writer should support roles #3407
Comments
Are you sure you'd want spans with classes to render as interpreted roles? Suppose you're converting some HTML to RST. Would you want every span with a class to come out as an interpreted role? That would presumably cause the RST document to be unprocessable with regular docutils, unless these roles were specially defined. |
And of course the same applies in reverse: if we don't render classes as roles, we probably shouldn't render roles as classes. An alternative for unknown roles would be to use a key-value attribute like |
Maybe RST roles should be treated analogous to the custom-style attribute we have for docx? i.e.
|
Ok this seemed to simple. Attribute name |
The docx writer simply adds those styles if they don't exist in the reference.docx... but maybe there should be a command-line option to strip all key-value attributes with key
Good point. I guess to some degree this is a philosophical question – whether a certain piece of markup information should go into an element, a class or an attribute. The three mechanisms are all equivalent in the sense that it's a relatively arbitrary choice between them:
I guess the reasoning for having So maybe you could tell us a bit more about what people usually use roles for in RST? P.S. Indeed, the |
As 2 cents to fuel the discussion, here is a use case for this feature. In rst2ipynb, we use pandoc to convert RST files to markdown and then Jupyter notebooks. Our main use case is to convert documents for SageMath which use a bunch of custom roles for other Sphinx-based tool chains. It would be nice if we could emulate those custom roles with pandoc one way or the other. For example, if the unknown roles were translated in one form or the other in the AST, we could use filters to process them. Thanks in advance! |
@nthiery could you provide a small code example? |
Hi @nichtich, This maybe not the greatest example since it's directly taken from the Sage source tree, but it shows typical use of roles like :func:, :ref:, :class:; we also have :wikipedia: or :trac: roles: For something really short, here is a made up example:
|
In the above examples, we would want to be able to provide hooks to customize the expansion of the |
Revisiting this question I think RST roles should be mapped to and from special attributes or class names like suggested by #3407 (comment). This would add another "special" attribute or class name-prefix in addition to
could be expressed in Pandoc Markdown with
Please note that there is a default role and some role names are mapped to other kind of markup. Try to convert this with Pandoc: .. default-role:: strong
`text` equals **text** equals :strong:`text`
.. default-role:: literal
`text` equals ``text`` equals :literal:`text`
.. default-role:: subscript
`text` equals :subscript:`text`
.. default-role:: custom
`text` equals :custom:`text` If RST roles are mapped to [text]{data-role=strong} equals **text** |
New user here. I came here in search of the ability to extend pandoc to add custom directives and roles for my rST documents. From the discussion, it looks like either can't really be possible right now. Am I understanding this correctly? I'd really like to add in a "me too please" on this. |
Roles are heavily used by RST tools so it would help to support them. At least interpreted text would be useful. Roles in RST are parsed anyway but ignored by now although they map nicely to
bracketed_spans
in Markdown. This already works:So this should also work with rst format:
And the expected reverse for rst writer:
The text was updated successfully, but these errors were encountered: