我怎样才能同时使用codehilite和美人鱼?

How can I use codehilite and mermaid together?

我们使用带有 material 主题的 mkdocs 生成文档,并且直到现在都使用 codehilite 扩展。我现在使用此处描述的方法添加了美人鱼:https://github.com/squidfunk/mkdocs-material/issues/693

首先,我的降价:

# Examples

## Mermaid
```mermaid
graph LR
    a[Start] -- b[(Storage)]-->d[End]
```
## Code

```
#!/usr/bin/python
import tensorflow as tf
```

我的mkdocs.yml:

# Project information
site_name: Test
site_description: 'Mermaid with CodeHiLite'

theme:
   name: material
   feature:
      tabs: false

extra_javascript:
   - 'custom_content/mermaid.min.js'

markdown_extensions:
   - codehilite

在此配置中,美人鱼代码未呈现为图表,但代码语法突出显示。

如果我像这样扩展 mkdocs.yml 来添加美人鱼:

# Project information
site_name: Test
site_description: 'Mermaid with CodeHiLite'
theme:
   name: material
   feature:
      tabs: false

extra_javascript:
   - 'custom_content/mermaid.min.js'

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

然后美人鱼图正确呈现,但代码未突出显示语法。

如果我更改 markdown 以将语言添加到代码块

``` python
#!/usr/bin/python
import tensorflow as tf
```

然后代码和图表都正确呈现。我遇到的问题是现有文档没有指定语言,直到现在才有效。

有什么想法可以让这两个扩展更好地协同工作吗?还是我只需要告诉开发人员更新他们的 markdown?

对于将美人鱼图集成到 mkdocs 中的预打包解决方案,现在有 mkdocs-mermaid2 插件,我正在维护它。

对于代码突出显示,它还包含一个如何使其与 superfences 插件一起工作的示例。

如果需要 pass arguments 美人鱼渲染器的 initialize() 方法来调整图表的外观,它可能特别有用。