Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fralau/mkdocs-mermaid2-plugin int…
Browse files Browse the repository at this point in the history
…o master
  • Loading branch information
Laurent Franceschetti committed Aug 29, 2021
2 parents e8552c9 + 149a4b1 commit ce62530
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![PyPI](https://img.shields.io/pypi/v/mkdocs-mermaid2-plugin)
![Downloads(Pypi)](https://img.shields.io/pypi/dm/mkdocs-mermaid2-plugin)
[![PyPI](https://img.shields.io/pypi/v/mkdocs-mermaid2-plugin)](https://pypi.org/project/mkdocs-mermaid2-plugin/)
![Downloads(PyPI)](https://img.shields.io/pypi/dm/mkdocs-mermaid2-plugin)


An [MkDocs](https://www.mkdocs.org/) plugin that renders textual graph
Expand Down Expand Up @@ -80,14 +80,14 @@ into segments `<pre><code class='mermaid>`:

<pre><div class="mermaid">
...
<\pre><\div>
</div></pre>

To make the HTML/css page more robust, the mermaid plugin converts
those segments into `<div>` elements in the final HTML page:

<div class="mermaid">
...
<\div>
</div>

It also inserts a call to the
[javascript library](https://github.com/mermaid-js/mermaid) :
Expand Down
19 changes: 11 additions & 8 deletions mermaid2/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ def mermaid_lib(self) -> str:
"""
Provides the actual mermaid library used
"""
mermaid_version = self.config['version']
lib = self.extra_mermaid_lib or MERMAID_LIB % mermaid_version
if not url_exists(lib):
raise FileNotFoundError("Cannot find Mermaid library: %s" %
lib)
return lib

if not hasattr(self, '_mermaid_lib'):
mermaid_version = self.config['version']
lib = self.extra_mermaid_lib or MERMAID_LIB % mermaid_version
if not url_exists(lib):
raise FileNotFoundError("Cannot find Mermaid library: %s" %
lib)
self._mermaid_lib = lib
return self._mermaid_lib

@property
def activate_custom_loader(self) -> bool:
Expand Down Expand Up @@ -153,6 +154,9 @@ def on_post_page(self, output_content, config, page, **kwargs):
Actions for each page:
generate the HTML code for all code items marked as 'mermaid'
"""
if "mermaid" not in output_content:
# Skip unecessary HTML parsing
return output_content
soup = BeautifulSoup(output_content, 'html.parser')
page_name = page.title
# first, determine if the page has diagrams:
Expand All @@ -171,7 +175,6 @@ def on_post_page(self, output_content, config, page, **kwargs):
pre_code_tags = (soup.select("pre code.mermaid") or
soup.select("pre code.language-mermaid"))
no_found = len(pre_code_tags)
# print("FOUND:", no_found)
if no_found:
info("Page '%s': found %s diagrams "
"(with <pre><code='[language-]mermaid'>), converting to <div>..." %
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from setuptools import setup, find_packages


<<<<<<< HEAD
VERSION = '0.5.2'
=======
VERSION = '0.6.0'
>>>>>>> 149a4b100454a05a4f14cccfd2acca605b0486e5

def readme():
"""print long description"""
Expand Down

0 comments on commit ce62530

Please sign in to comment.