Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mermaid markdown documentation & visualization enhancement #4170

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Alyxion
Copy link
Contributor

@Alyxion Alyxion commented Jan 3, 2025

I added the missing documentation for how to use Mermaid in the Markdown component.

While doing so I realized that there is a display error, showing the mermaid diagrams source code for about half a second whenever a page is refreshed containing the markdown component using mermaid:

If you run this application

from nicegui import ui

@ui.page('/')
def main():
    with ui.grid(columns=2):
        with ui.card():
            ui.markdown('''### Architecture Overview
  ```mermaid
  flowchart TB
      subgraph Frontend
          Browser[Browser/Client]
          Vue[Vue.js Components]
      end
      subgraph Backend
          Server[NiceGUI Server]
          Python[Python Handlers]
      end
      Browser <--> Vue
      Vue <-.->|WebSocket| Server
      Server <--> Python
  ```
  
  ### State Diagram
  
  ```mermaid
  stateDiagram-v2
      [*] --> Init: Start App
      Init --> Ready: Load UI
      Ready --> Processing: Event
      Processing --> Ready: Update UI
      Processing --> Error: Exception
      Error --> Ready: Handle Error
      Ready --> [*]: Close
  ```
  ''', extras=['mermaid'])

ui.run()

Making use of Mermaids data-processed attribute and waiting for the graphs being rendered seemes to resolve this issue.

* Fixed a bug which caused mermaid source code to be temporarily visible upon page refresh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant