-
I am having trouble adding custom icons with Markdown inside a custom theme that extends this theme. I'm able to use a custom icon placed in the custom theme I've looked at #5199, and I seem to have a similar problem, but the structure of the project and the goal is not the same. File structureAvailable at: https://github.com/joapuiib/mkdocs-custom-theme
Plugin installationI've installed my plugin via ~/mkdocs-custom-theme $ pip install . What I've triedI have tried to configure the plugin in markdown_extensions:
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
options:
custom_icons:
- custom_theme/.icons
However, this configuration fails when deploying (https://github.com/joapuiib/mkdocs-custom-theme/actions/runs/9964680935/job/27533499144) Also, I have tried installing the package locally and using it in another project. I can use the custom icons in the configuration, but not as an emoji. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @joapuiib, mkdocs-material/material/extensions/emoji.py Lines 71 to 98 in 6b13c56 The paths in:
are relative to the current working directory, they're not going to be resolved against the extended theme. |
Beta Was this translation helpful? Give feedback.
-
It was easier than I thought. I have solved it by adding my own emoji extension and configuring it in
import os
from inspect import getfile
from markdown import Markdown
from material.extensions.emoji import _load_twemoji_index
import custom_theme
# Create twemoji index
def twemoji(options: object, md: Markdown):
paths = options.get("custom_icons", [])[:]
root = os.path.dirname(getfile(custom_theme))
root = os.path.join(root, ".icons")
paths.append(root)
return _load_twemoji_index(tuple(paths)) In markdown_extensions:
- pymdownx.details
- pymdownx.emoji:
emoji_index: !!python/name:custom_theme.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
I have had to add a recursive-include custom_theme *.ico *.js *.css *.png *.html *.eot *.svg *.ttf *.woff *.html *.py
recursive-exclude * __pycache__
recursive-exclude * *.py[co] Thanks @kamilkrzyskow for your help. |
Beta Was this translation helpful? Give feedback.
It was easier than I thought.
I have solved it by adding my own emoji extension and configuring it in
mkdocs.yml
custom_theme/extensions/emoji.py
In
mydocs.yml
: