-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (28 loc) · 1 KB
/
main.py
File metadata and controls
36 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import re
def define_env(env):
"""
This is the hook for defining variables, macros and filters
- variables: the dictionary that contains the environment variables
- macro: a decorator function, to declare a macro.
- filter: a decorator function, to declare a filter.
"""
@env.filter
def regex_replace(s, find, replace):
"""A non-jinja default re.sub()."""
return re.sub(find, replace, s)
def on_pre_page_macros(env):
"""
Actions to be done before macro interpretation,
just before the markdown is generated
"""
# base URI of the page (with versioning support)
env.page.meta['base_uri'] = re.sub(
env.page.file.page.url, '', env.page.canonical_url)
def on_post_page_macros(env):
"""
Actions to be done after macro interpretation,
just before the markdown is generated
"""
# base URI of the page (with versioning support)
env.page.meta['base_uri'] = re.sub(
env.page.file.page.url, '', env.page.canonical_url)