Skip to content

Commit 3895760

Browse files
committed
Version 2.1.0
1 parent 4f0e18d commit 3895760

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The content is encrypted with AES-256 in Python using PyCryptodome, and decrypte
2828
* [Features](#features)
2929
* [HighlightJS support](#highlightjs-support) *(default)*
3030
* [Arithmatex support](#arithmatex-support) *(default)*
31+
* [Mermaid2 support](#mermaid-support) *(default)*
3132
* [Tag encrypted page](#tag-encrypted-page) *(default)*
3233
* [Rebember password](#rebember-password)
3334
* [Encrypt something](#encrypt-something)
@@ -50,7 +51,7 @@ Install the package from source with pip:
5051
```bash
5152
cd mkdocs-encryptcontent-plugin/
5253
python3 setup.py sdist bdist_wheel
53-
pip3 install dist/mkdocs_encryptcontent_plugin-2.0.2-py3-none-any.whl
54+
pip3 install dist/mkdocs_encryptcontent_plugin-2.1.0-py3-none-any.whl
5455
```
5556

5657
Enable the plugin in your `mkdocs.yml`:
@@ -62,6 +63,7 @@ plugins:
6263
```
6364
> **NOTE:** If you have no `plugins` entry in your configuration file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.
6465

66+
6567
# Usage
6668

6769
Add an meta tag `password: secret_password` in your markdown files to protect them.
@@ -143,6 +145,24 @@ MathJax.typesetPromise()
143145

144146
> **NOTE** It has been tested in Arithmatex `generic` mode only.
145147

148+
### Mermaid2 support
149+
150+
> **Enable by default**
151+
152+
Related to [issue #22](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/22)
153+
154+
If mermaid2 plugin is detected in your configuration to generate graph from text, reload renderer after decryption process. If the Mermaid2 plugin is not correctly detected, you can force the detection by adding `mermaid2: True` on the plugin configuration or set `mermaid2: False` to disable this feature.
155+
156+
When enable, the following part of the template is add to force graph rendering on decrypted content.
157+
158+
```jinja
159+
{% if mermaid2 %}
160+
mermaid.contentLoaded();
161+
{% endif %}
162+
```
163+
164+
> **NOTE** It has been tested with Mermaid2 mkdocs plugin only.
165+
146166
### Tag encrypted page
147167

148168
> **Enable by default**

encryptcontent/decrypt-contents.tpl.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ function decrypt_action(password_input, encrypted_content, decrypted_content) {
152152
{% if arithmatex -%}
153153
if (typeof MathJax === 'object') { MathJax.typesetPromise(); };
154154
{%- endif %}
155+
{% if mermaid2 -%}
156+
if (typeof mermaid === 'object') { mermaid.contentLoaded(); };
157+
{%- endif %}
155158
{% if hljs -%}
156159
document.getElementById("mkdocs-decrypted-content").querySelectorAll('pre code').forEach((block) => {
157160
hljs.highlightBlock(block);

encryptcontent/plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class encryptContentPlugin(BasePlugin):
6363
('password', config_options.Type(string_types, default=None)),
6464
('arithmatex', config_options.Type(bool, default=True)),
6565
('hljs', config_options.Type(bool, default=True)),
66+
('mermaid2', config_options.Type(bool, default=True)),
6667
('remember_password', config_options.Type(bool, default=False)),
6768
('default_expire_dalay', config_options.Type(int, default=int(24))),
6869
('tag_encrypted_page', config_options.Type(bool, default=True)),
@@ -126,6 +127,7 @@ def __generate_decrypt_js__(self):
126127
# enable / disable features
127128
'arithmatex': self.config['arithmatex'],
128129
'hljs': self.config['hljs'],
130+
'mermaid2': self.config['mermaid2'],
129131
'remember_password': self.config['remember_password'],
130132
'default_expire_dalay': int(self.config['default_expire_dalay']),
131133
'encrypted_something': self.config['encrypted_something'],
@@ -161,6 +163,13 @@ def on_config(self, config, **kwargs):
161163
else:
162164
logger.info('"arithmatex" feature is disabled in your plugin configuration.')
163165
self.config['arithmatex'] = False
166+
# Check if mermaid feature need to be enabled, based on plugin configuration
167+
if config['plugins'].get('mermaid2') and self.config['mermaid2'] is not False:
168+
logger.debug('"mermaid2" value detected on extensions config, enable rendering after decryption.')
169+
self.config['mermaid2'] = True
170+
else:
171+
logger.info('"mermaid2" feature is disabled in your plugin configuration.')
172+
self.config['mermaid2'] = False
164173
# Warn about deprecated features on Vervion 2.0.0
165174
deprecated_options_detected = False
166175
if self.config.get('disable_cookie_protection'):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read(fname):
1111

1212
setup(
1313
name='mkdocs-encryptcontent-plugin',
14-
version='2.0.2',
14+
version='2.1.0',
1515
author='CoinK0in',
1616
author_email='[email protected]',
1717
description='A MkDocs plugin that encrypt/decrypt markdown content with AES',

0 commit comments

Comments
 (0)