-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmain.py
More file actions
22 lines (20 loc) · 799 Bytes
/
main.py
File metadata and controls
22 lines (20 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import materialx.emoji
from markdown import markdown
def define_env(env):
@env.macro
def codebox(*, title, language, filepath):
editLink = f"""{env.variables['config']['repo_url']}tree/{env.variables['config']['edit_uri'].split("/")[1]}/snippets/{filepath}"""
icon = markdown(':material-link:',
extensions=['pymdownx.emoji'],
extension_configs={
'pymdownx.emoji': {
'emoji_index': materialx.emoji.twemoji,
'emoji_generator': materialx.emoji.to_svg
}
}
).replace('<p>', '').replace('</p>', '')
return f"""
```{language} title='{title} <a class="codeBoxTitleGitHubLink" href="{editLink}" title="View on GitHub">{icon}</a>'
--8<-- "{filepath}"
```
"""