reStructuredText is a great markup, but sometimes you just need to have things like this, but you can’t do it with default settings. However, it’s very simple to enable the use of raw HTML for inline formatting with Custom Interpreted Text Roles just as you use raw directive. The following is an example of using the new role for strike through text, with <del> or <strike>:
.. role:: raw-html(raw)
:format: html
[...] things like :raw-html:`<del>this</del>`, [...]
This raw-html is for every HTML you need, that is you can put anything you want in it, but if you want to create a more specific for one element, you can register one, for instance, I have done for <kbd> because it’s almost unavoidable to mark up keys in a blog like this.
You can also use this role to nest text with different inline markups in raw HTML, for example
:raw-html:`<em>different <strong>inline</strong> markups</em>`
It seems more seamless than nesting using substitution and raw directive, although I don’t think either is good, keep your markup simple, no need to distract readers with fancy and complicated markups.
Of course, you must configure the parser to be raw_enabled.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.