Add an example for the alteration of icons on runtime
[GitHub/WoltLab/woltlab.github.io.git] / main.py
CommitLineData
bcc4cb57
MS
1import materialx.emoji
2from markdown import markdown
3
3c732517
MS
4def define_env(env):
5 @env.macro
43f484af
TD
6 def codebox(*, title, language, filepath):
7 editLink = f"""{env.variables['config']['repo_url']}tree/{env.variables['config']['edit_uri'].split("/")[1]}/snippets/{filepath}"""
8 icon = markdown(':material-link:',
9 extensions=['pymdownx.emoji'],
10 extension_configs={
11 'pymdownx.emoji': {
12 'emoji_index': materialx.emoji.twemoji,
13 'emoji_generator': materialx.emoji.to_svg
14 }
15 }
16 ).replace('<p>', '').replace('</p>', '')
17
18 return f"""
afe46114
TD
19```{language} title='{title} <a class="codeBoxTitleGitHubLink" href="{editLink}" title="View on GitHub">{icon}</a>'
20--8<-- "{filepath}"
21```
3c732517 22"""