Skip to content

Compatibility with Docxbuilder #103

Description

@amhest

Is your feature request related to a problem? Please describe.
I have a large rst document which works well with latexpdf but looking to use docx instead via docxbuilder. Document has a mix of images, plantuml and drawio. I followed these instructions for plantuml and it works great but can't get drawio to do something similar; I get this error for every image:

docs/src/arch/02_goals.rst:51: WARNING: cannot identify image file 'docs/src/arch/02_hardware_diagram.drawio'

Describe the solution you'd like
Does sphinxcontrib-drawio generate a well-formed docutils document tree as required by the link above?

If so, I think adding something like this to my conf.py (as instructed above for plantuml) should also work for drawio but I'm not sure I'm finding the right node names etc. I would appreciate your advice.

def setup(app):
    def docx_visit_drawio(self, node):
        def get_filepath(self, node):
            from sphinxcontrib import drawio
            _, filepath = drawio.DrawIOConverter.handle(self, node)
            return filepath
        alt = node.get('alt', (node['drawio'], None))
        # Docxbuilder provides useful methods. See Docxbuilder API reference.
        self.visit_image_node(node, alt, get_filepath)
    # Add the visit method to Docxbuilder
    import docxbuilder
    translator = docxbuilder.DocxBuilder.default_translator_class
    setattr(translator, 'visit_drawio_node', docx_visit_drawio)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions