3

I would like to create a custom directive that functions similar to docutil's list-table element, where I provide a list of arguments afterwards and use them to render a html table with a custom layout. I have tried modifying the helloworld example provided here, but am unsure how to parse the provided bulletpoints and return a table.

Here is what I have so far:

def run(self):
    html_placeholder = "<table></table>"
    paragraph_node = nodes.paragraph(text='.. raw:: html\n\n{}'.format(html_placeholder)
    return [paragraph_node]


def setup(app):
    app.add_directive("format_table", FormatTable)

    return {
        'version': '0.1',
        'parallel_read_safe': True,
        'parallel_write_safe': True,
    }

Is there a good solution to replace the directive delaration with the required html code?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Yes
  • 339
  • 3
  • 19

0 Answers0