Skip to content

Get access to Mermaid's generated SVG code #4035

Closed Answered by falkoschindler
groucho86 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @groucho86,

Even though there is no explicit function for doing that, you might be able to create a workaround using ui.run_javascript:

@ui.page('/')
def index():
    m = ui.mermaid('''
    graph TD
        A --> B
        B --> C
    ''')

    async def get_svg():
        svg = await ui.run_javascript(f'getElement({m.id}).$el.querySelector("svg").outerHTML')
        print(svg)

    ui.button('Get SVG', on_click=get_svg)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@groucho86
Comment options

Answer selected by groucho86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants