You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-20Lines changed: 60 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,47 +188,87 @@ plugins:
188
188
password_button_text: 'custome_text_button'
189
189
```
190
190
191
-
### Encrypt Table Of Content
191
+
### [:wrench: BETA] Encrypt Something
192
192
193
193
Related to [issue #9](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin/issues/9)
194
194
195
-
You can add `encrypted_toc: True` in plugin config variable, to encrypt the table of contents.
195
+
You **have to** enable [feature tag encrypt page](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#tag-encrypted-page) for this feature to work properly.
196
196
197
-
You **have to** enable [feature tag encrypt page](https://github.com/CoinK0in/mkdocs-encryptcontent-plugin#tag-encrypted-page)
198
-
for this feature to work properly, cause HTML generation of the Table Of Content is done after the rendering process.
197
+
Add `encrypted_something: {}` in the plugin configuration variable, to encrypt something else.
199
198
200
-
When this feature is enabled, we search for your table of content based on `id=mkdocs-encrypted-toc` and encrypt all HTML content.
199
+
The syntax of this new variable **MUST** follow the yaml format of a dictionary.
200
+
Child elements of `encrypted_something` are build with a key `<unique name>` in string format and a list as value.
201
+
The list have to be contructed with the name of an HTML element `<html tag>` as first item and `id` or `class` as the second item.
201
202
202
203
```yaml
203
-
plugins:
204
-
- encryptcontent:
205
-
tag_encrypted_page: True
206
-
encrypted_toc: True`
204
+
encrypted_something:
205
+
<uniq name>: [<html tag>, <'class' or 'id'>]
207
206
```
208
207
209
-
Adding `id=mkdocs-encrypted-toc` in the parent element of your table of content, so that the child html contained to be encrypted.
210
-
It possible to use conditional tag `page.encrypted` to add or not the id.
208
+
The `<unique name>` key identifies the name of a specific element of the page that will be searched by beautifulSoup.
209
+
The first value of the `<html tag>` list identifies the type of HTML tag in which the name is present.
210
+
The second value of the list, as string `'id'` or `'class'`, specifies the type of the attribute which contains the unique name in the html tag.
211
+
212
+
Prefer to use an `'id'`, however depending on the template of your theme, it is not always possible to use the id.
213
+
So we can use the class attribute to define your unique name inside html tag.
214
+
BeautifulSoup will encrypt all HTML elements discovered with the class.
215
+
216
+
When the feature is enabled, you can use any methods *(password, button, cookie)* to decrypt every elements encrypted on the page.
217
+
218
+
By default **every child items** are encrypted and the encrypted elements have `style=display:none` to hide their content.
219
+
220
+
#### How to use it :exploding_head: ?! Examples
221
+
222
+
Use the `page.encrypted` conditions to add attributes of type id or class in the HTML templates of your theme.
223
+
Each attribute is identified with a unique name and is contained in an html element.
224
+
Then add these elements in the format of a yaml dictionary under the variable `encrypted_something`.
225
+
226
+
1. For example, encrypt ToC in a theme where ToC is under 'div' element like this :
211
227
212
228
```jinja
213
-
{%- if page.toc|count > 0 %}
214
229
<div class=".." {% if page.encrypted %}id="mkdocs-encrypted-toc"{% endif %}>
0 commit comments