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 doesn't render when network is not available #3781

Closed
5 tasks done
gyund opened this issue Mar 29, 2022 · 2 comments
Closed
5 tasks done

Mermaid doesn't render when network is not available #3781

gyund opened this issue Mar 29, 2022 · 2 comments
Labels
resolved by config change Issue can be mitigated by the reporter

Comments

@gyund
Copy link

gyund commented Mar 29, 2022

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

If you are writing documentation and you lose access to the internet, mermaid diagrams render as code blocks instead of the diagrams.

Expected behaviour

Mermaid diagrams are rendered

Actual behaviour

Mermaid does not display the diagram as an image when network access is unavailable.

Steps to reproduce

  1. Follow these directions for setting up mermaid support: https://squidfunk.github.io/mkdocs-material/reference/diagrams/
  2. Create a mermaid codeblock in a markdown file (take any example from the link above)
  3. run mkdocs serve and verify the diagram is displayed
  4. Disable your network adapter (or unplug your network cable)
  5. Refresh the page. The diagram is now rendered as a codeblock

Package versions

  • Python: Python 3.8.10
  • MkDocs: mkdocs, version 1.3.0
  • Material: Version: 8.2.8

Configuration

site_name: My Docs
theme: material

markdown_extensions:
  - pymdownx.superfences:
      custom_fences:
        - name: mermaid
          class: mermaid
          format: !!python/name:pymdownx.superfences.fence_code_format

System information

  • Operating system: Ubuntu 20.04
  • Browser: Chrome / Firefox
@squidfunk
Copy link
Owner

Thanks for reporting. Mermaid.js is loaded from a CDN, which is why local browsing still works, except for assets loaded from third-party servers. You can either provide your own Mermaid.js via extra_javascript, or use the Privacy Plugin to download all assets automatically.

Related:

@squidfunk squidfunk added the resolved by config change Issue can be mitigated by the reporter label Mar 29, 2022
@gyund
Copy link
Author

gyund commented Mar 29, 2022

Thanks, the extra_script approach worked after downloading unpkg.com/mermaid@8.13.3/dist/mermaid.min.js from #3742 and dropping it into the folder. In case anyone else has the issue, that's the easiest way. Just update the version in the url as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved by config change Issue can be mitigated by the reporter
Projects
None yet
Development

No branches or pull requests

2 participants