How to embed HTML or XML in reStructuredText (sphinx) so the browser cna render them?

I just need to embed a small piece of html or xml in the reStructuredText (sphinx) so that the browser can render them in the generated HTML files, like the following little piece

.. raw:: html <a href="testurl">testurl</a> 

or

.. raw:: html <math><apply><plus/><ci>a</ci><apply><minus/><ci>b</ci><ci>c</ci></apply></apply></math> 

No matter I tried directives like "literal", "raw", "container", "code", either the html code is displayed as the inner text of some "p" block (so the browser display the code rather than render it), or the code just disappear from the output.

What is the correct way to embed html or xml in the reStructuredText (sphinx) so the browser can render them? I just want to html or xml just be placed there intact.

1 Answer

You need to add a blank line between the raw directive and your code.

.. raw:: html <a href="testurl">testurl</a> 

I would suggest indenting 4 spaces to be consistent with Python formatting, but 2 is fine.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like