|
@@ -19,7 +19,12 @@ from functools import wraps
|
|
|
# Define some regular expressions
|
|
|
LIQUID_TAG = re.compile(r'\{%.*?%\}')
|
|
|
EXTRACT_TAG = re.compile(r'(?:\s*)(\S+)(?:\s*)')
|
|
|
-
|
|
|
+LT_CONFIG = { 'CODE_DIR': 'code',
|
|
|
+ 'NOTEBOOK_DIR': 'notebooks'
|
|
|
+}
|
|
|
+LT_HELP = { 'CODE_DIR' : 'Code directory for include_code subplugin',
|
|
|
+ 'NOTEBOOK_DIR' : 'Notebook directory for notebook subplugin'
|
|
|
+}
|
|
|
|
|
|
class _LiquidTagsPreprocessor(markdown.preprocessors.Preprocessor):
|
|
|
_tags = {}
|
|
@@ -51,6 +56,18 @@ class _LiquidTagsPreprocessor(markdown.preprocessors.Preprocessor):
|
|
|
|
|
|
class LiquidTags(markdown.Extension):
|
|
|
"""Wrapper for MDPreprocessor"""
|
|
|
+ def __init__(self, config):
|
|
|
+ try:
|
|
|
+ # Needed for markdown versions >= 2.5
|
|
|
+ for key,value in LT_CONFIG.items():
|
|
|
+ self.config[key] = [value,LT_HELP[key]]
|
|
|
+ super(LiquidTags,self).__init__(**config)
|
|
|
+ except AttributeError:
|
|
|
+ # Markdown versions < 2.5
|
|
|
+ for key,value in LT_CONFIG.items():
|
|
|
+ config[key] = [config[key],LT_HELP[key]]
|
|
|
+ super(LiquidTags,self).__init__(config)
|
|
|
+
|
|
|
@classmethod
|
|
|
def register(cls, tag):
|
|
|
"""Decorator to register a new include tag"""
|