@@ -51,6 +51,7 @@ class encryptContentPlugin(BasePlugin):
5151 ('encryption_info_message' , mkdocs .config .config_options .Type (string_types , default = str (settings ['encryption_info_message' ]))),
5252 ('global_password' , mkdocs .config .config_options .Type (string_types , default = None )),
5353 ('password' , mkdocs .config .config_options .Type (string_types , default = None )),
54+ ('arithmatex' , mkdocs .config .config_options .Type (bool , default = False )),
5455 ('hljs' , mkdocs .config .config_options .Type (bool , default = False )),
5556 ('remember_password' , mkdocs .config .config_options .Type (bool , default = False )),
5657 ('disable_cookie_protection' , mkdocs .config .config_options .Type (bool , default = False )),
@@ -99,6 +100,7 @@ def __encrypt_content__(self, content):
99100 'ciphertext_bundle' : b';' .join (ciphertext_bundle ).decode ('ascii' ),
100101 'js_libraries' : JS_LIBRARIES ,
101102 # enable / disable features
103+ 'arithmatex' : self .arithmatex ,
102104 'hljs' : self .hljs ,
103105 'remember_password' : self .remember_password ,
104106 'disable_cookie_protection' : self .disable_cookie_protection ,
@@ -134,7 +136,7 @@ def on_pre_build(self, config):
134136 # Check if decryption_failure_message description is set on plugin configuration to overwrite
135137 decryption_failure_message = plugin_config .get ('decryption_failure_message' )
136138 setattr (self , 'decryption_failure_message' , decryption_failure_message )
137- # Check if encryption_info_message descruption is set on plugin configuration to overwrite
139+ # Check if encryption_info_message description is set on plugin configuration to overwrite
138140 encryption_info_message = plugin_config .get ('encryption_info_message' )
139141 setattr (self , 'encryption_info_message' , encryption_info_message )
140142 # Check if hljs feature need to be enabled, based on theme configuration
@@ -143,6 +145,10 @@ def on_pre_build(self, config):
143145 highlightjs = config ['theme' ]._vars ['highlightjs' ]
144146 if highlightjs :
145147 setattr (self , 'hljs' , highlightjs )
148+ # Check if pymdownx.arithmatex feature need to be enabled, based on markdown_extensions configuration
149+ setattr (self , 'arithmatex' , None )
150+ if 'pymdownx.arithmatex' in config ['markdown_extensions' ]:
151+ setattr (self , 'arithmatex' , True )
146152 # Check if tag_encrypted_page feature is enable: add an extra attribute `encrypted` is add on page object
147153 setattr (self , 'tag_encrypted_page' , False )
148154 if 'tag_encrypted_page' in plugin_config .keys ():
@@ -173,7 +179,6 @@ def on_pre_build(self, config):
173179 encrypted_something = self .config .get ('encrypted_something' )
174180 setattr (self , 'encrypted_something' , encrypted_something )
175181
176-
177182 def on_page_markdown (self , markdown , page , config , ** kwargs ):
178183 """
179184 The page_markdown event is called after the page's markdown is loaded from file and
@@ -189,7 +194,7 @@ def on_page_markdown(self, markdown, page, config, **kwargs):
189194 """
190195 if 'password' in page .meta .keys ():
191196 page_password = page .meta .get ('password' )
192- # If global_password is set, but you dont want to encrypt content
197+ # If global_password is set, but you don't want to encrypt content
193198 if page_password == '' :
194199 setattr (self , 'password' , None )
195200 else :
@@ -244,7 +249,7 @@ def on_post_page(self, output_content, page, config, **kwargs):
244249 #print({'name': name, 'html tag': tag[0], 'type': tag[1]})
245250 something_search = soup .findAll (tag [0 ], { tag [1 ]: name })
246251 if something_search is not None and len (something_search ) > 0 :
247- # Loop for multi childs tags on target element
252+ # Loop for multi child tags on target element
248253 for item in something_search :
249254 # Remove '\n', ' ' useless content generated by bs4 parsing...
250255 item .contents = [content for content in item .contents if not content in ['\n ' , ' ' ]]
@@ -255,7 +260,7 @@ def on_post_page(self, output_content, page, config, **kwargs):
255260 merge_item = item .contents [0 ]
256261 else :
257262 merge_item = ""
258- # Encrypt childs items on target tags with page password
263+ # Encrypt child items on target tags with page password
259264 cipher_bundle = self .__encrypt_text_aes__ (merge_item , page .password )
260265 encrypted_content = b';' .join (cipher_bundle ).decode ('ascii' )
261266 # Replace initial content with encrypted one
@@ -269,4 +274,4 @@ def on_post_page(self, output_content, page, config, **kwargs):
269274 else :
270275 item ['style' ] = "display:none"
271276 output_content = str (soup )
272- return output_content
277+ return output_content
0 commit comments