Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support the #only-dark and #only-light feature of mkdocs-material by setting the data-gallery attribute #49

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Xiaokang2022
Copy link

feat: #26

I've added a configuration option called auto_themed, which defaults to False. Set it to True to support the #only-dark and #only-light feature of mkdocs material.

Support both ![]() and <img> formats.

How it works?

According to https://blueswen.github.io/mkdocs-glightbox/gallery/gallery/, we can solve this problem by inserting the data-gallery attribute depending on whether the image element contains a special fragment(e.g #only-dark) or not.

Supported fragments are: #only-dark, #only-light, #gh-dark-mode-only and #gh-light-mode-only.

return html

markdown = re.sub("!\\[[^\\]]*\\]\\([^)]*\\)", repl_md, markdown)
markdown = re.sub("<img.*>", repl_html, markdown)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to make that match non-greedy to not get two img tags at once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants