-
Notifications
You must be signed in to change notification settings - Fork 27
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
Local Mermaid library not found #90
Comments
🤔 There should be a logical explanation. Hints:
|
When I browse to
It seems that the path to the Mermaid library injected into the HTML should be prepended with |
Perhaps I am missing something. What is the hierarchy of your mkdocs project? |
Here’s the general hierarchy:
The page generated for |
Here is a change I made locally that allows the diagrams to render: diff --git a/mermaid2/plugin.py b/mermaid2/plugin.py
index 8bbfe31..27a9673 100755
--- a/mermaid2/plugin.py
+++ b/mermaid2/plugin.py
@@ -276,7 +276,10 @@ class MarkdownMermaidPlugin(BasePlugin):
else:
# <script src="...">
# generally for self.mermaid_major_version < 10:
- new_tag['src'] = self.javascript
+ if self.javascript.startswith("http"):
+ new_tag['src'] = self.javascript
+ else:
+ new_tag['src'] = os.path.relpath(self.javascript, os.path.dirname(page.url))
# it's necessary to close and reopen the tag:
soup.body.append(new_tag)
new_tag = soup.new_tag("script")
|
🤔 When doing the build, the idea is that the javascript file must be copied in the subdirectory of the There is a test site under We do have a problem; I would have to see how MkDocs solved it with What result does it give you for |
I tested with My patch generates a relative link that fetches the root directory of the site. In my case, it generates script tags that look like so: <script src="../js/mermaid.min.js"></script> It should work for arbitrarily nested subdirectories (i.e. add as many Ideally it should probably use an absolute path, but I haven’t found how to do that rapidly enough for a PoC: <script src="/mysite/js/mermaid.min.js"></script> |
Any progress on this? Maybe my workaround could be shipped in a new version, until a more robust solution is developed? |
- Fixed error of incorrect call to javascript library (the relative path was not being adapted)
Fixed in 1.1.1 (github); I took inspiration from the solution you proposed. Let me know if it works for you? |
Looks good! I also tried with a doubly-nested document, the Feel free to close this issue once v1.1.1 has officially tagged/released! |
Released on Pypi, as v1.1.1. |
Hi,
This is a follow-up to #84.
My configuration is as follows:
The library is located in
/docs/js
.The documentation that makes use of Mermaid is located in
/docs/subdir
.At runtime, I can see in the console that runs the development server:
Diagrams are still rendered, however, because the plugin fetches the library from unpkg.com.
Thanks!
The text was updated successfully, but these errors were encountered: