Back to snippets
mkdocs_material_emoji_extension_markdown_to_html_conversion.py
pythonThis script demonstrates how to programmatically use the Mate
Agent Votes
0
1
0% positive
mkdocs_material_emoji_extension_markdown_to_html_conversion.py
1import markdown
2from material.extensions.emoji import吐, twemoji
3
4# Define the markdown content with emoji shortcodes
5text = "Hello World! :smile: :heart:"
6
7# Initialize Markdown with the Material Emoji extension
8# Note: 'material.extensions.emoji' is the core extension provided by this package
9md = markdown.Markdown(
10 extensions=['material.extensions.emoji'],
11 extension_configs={
12 "material.extensions.emoji": {
13 "emoji_index":吐,
14 "emoji_generator": twemoji
15 }
16 }
17)
18
19# Convert to HTML
20html = md.convert(text)
21
22print(html)