-
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
super fences configuration prevents loading additional icon packs #111
Comments
Thank you for your contribution! This is very appreciated. |
The problem seems to be, here, in the Javascript code, possibly in relation to the HTML tags that enclose the javascript ( It is important to keep in mind that the plugin does not do any Javascript, except for inserting calls to the library and initialization sequences.
|
So the problem doesn't appear to be with Mermaid or this plugin. It looks like Material theme for Mkdocs has added support for Mermaid since v8.2.0. Their implementation seems to be interfering with this plugin. I switched to the Cinder theme and was able to use this plugin and load the custom icon packs without any issues. |
Thanks, and it's good that you got it working. If you still wish to use Material, you could try to use its own recommended custom fence (just in case, to see what happens)? If all else fails, you might want to open a discussion on Material's github repo? I'm interested in that issue, since I am in the process of impletementing test cases for Superfences on the Mermaid2 plugin, using Mkdocs-Test. (I'm putting @squidfunk in copy, just in case.) |
You don't need to use our integration, which is targeted towards more consistent look and feel but might make more advanced Mermaid.js functionality harder to use. You can always use a custom integration, just don't add the We currently have no plans to add further functionality to our Mermaid integration. |
@squidfunk Would it be possible to add the ability to disable the Material mermaid integration altogether? If I'm understanding you correctly you're saying that if mermaid2 were configured to use a different query selector than .mermaid, and the custom fence output that different class on it's generated element then the Material integration mermaid wouldn't interfere with the mermaid2 plugin. Did I get that correct? @fralau would this be possible to do without modifications to mermaid2? Thanks to both of you for your attention to this. |
So after some quick testing I got this working: plugins:
- search
- mermaid2:
version: 11.4.0
arguments:
securityLevel: 'loose'
startOnLoad: false
markdown_extensions:
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: diagram
format: !!python/name:mermaid2.fence_mermaid extra javascript file: import mermaid from 'https://unpkg.com/[email protected]/dist/mermaid.esm.min.mjs'
document$.subscribe(function() {
console.log("Initialize third-party libraries here")
mermaid.registerIconPacks([
{
name: 'logos',
loader: () =>
fetch('https://unpkg.com/@iconify-json/logos@1/icons.json').then((res) => res.json()),
},
{
name: 'aws',
loader: () =>
fetch('/assets/js/aws-logos.json').then((res) => res.json()),
}
])
mermaid.run({querySelector: '.diagram'});
}); That loads the extra icon packs, and still enables syntax highlighting. Edit: |
As already mentioned in #111 (comment), just use another class, as you did in #111 (comment) with |
@squidfunk Thanks for your help! @mgrubb Is my understanding correct that you used the |
I used the plugins:
- mermaid:
iconPacks:
- name: logos
url: https://unpkg.com/..... And have the plugin generate the call to |
@mgrubb Thanks for you useful feedback! I agree with you that this use case might not be common, and does not warrant a development for the moment. However, it has one merit; it shows that the Here is, for the record, an important point concerning Mkdocs-Mermaid2:
This is what allowed your workaround to work, and I am glad that I took that precaution! Take-away: MkDocs-Mermaid2 should continue to support |
Finally @squidfunk: this is the opportunity to say that MkDocs, aside of being a good piece of software, owes some of its success to a friendly community of people with diverse backgrounds and competences. |
TODO: update documentation, to clarify the role of |
I'm trying to get Mermaid's new architecture-beta diagram type working along with loading additional icon resources shown (here)[https://mermaid.js.org/syntax/architecture.html#icons].
I've created a javascript file to be used with the
extra_javascript
key in themkdocs.yml
file that calls themermaid.registerIconPacks
function from the Mermaid documentation referenced above.When I have the superfences configuration set as referenced by the mermaid2 documentation as (here)[https://github.com/fralau/mkdocs-mermaid2-plugin?tab=readme-ov-file#additional-settings-for-the-material-theme] the icon packs won't load. When I remove the superfences configuration then the icon packs load as expected, but of course syntax highlighting breaks.
I've tried adding the
registerIconPacks
call directly in the plugin to have it in the same script block but that doesn't seem to make a difference. I've also tried explicitly calling initialize in myextra_javascript
file while having the superfences config enabled but that didn't seem to make a difference. Though when using the superfences configuration it doesn't appear as thoughmermaid.initialize()
is called at all. I could not find any reference towindow.mermaidConfig
being used after it is set by the script tag created by the plugin when using superfences, so I'm not clear how that works.Any advice on how to get this to work with superfences enabled?
The text was updated successfully, but these errors were encountered: