Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/temperlang/svg-inline-mkdocs-plugin
A plugin for mkdocs that inlines select SVG markdown images (`![](foo.svg)`) so that links in the SVG work without breaking SVG icons
https://github.com/temperlang/svg-inline-mkdocs-plugin
mkdocs plugin svg
Last synced: 3 months ago
JSON representation
A plugin for mkdocs that inlines select SVG markdown images (`![](foo.svg)`) so that links in the SVG work without breaking SVG icons
- Host: GitHub
- URL: https://github.com/temperlang/svg-inline-mkdocs-plugin
- Owner: temperlang
- License: apache-2.0
- Created: 2023-11-07T16:40:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-09T00:26:26.000Z (about 1 year ago)
- Last Synced: 2024-09-30T22:15:08.546Z (3 months ago)
- Topics: mkdocs, plugin, svg
- Language: Python
- Homepage: https://pypi.org/project/mkdocs-plugin-inline-ext-svg/
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mkdocs Plugin to inline SVGs
A [MkDocs plugin] that inlines SVG images matching a pattern into the output without inlining Materials theme icons.
This differs from previously developed plugins in several ways:
- it does not use a regex to find images in Markdown. It parses the
generated HTML, and
- it can be configured to only inline SVGs with paths matching a
pattern, and
- it parses the SVG and removes SVG elements that are marked
`.do-not-inline`.----
This plugin operates post HTML generation looking for `img` elements like
```html
```When the *src* is a path-local URL with a path component that ends
with `.svg` and it matches the configured pattern then the file is
read from the local file system and inlined in place.Alt text is ignored in favour of any SVG `` element.
If the SVG contains any elements marked with `class="do-not-inline"`,
they will not be included in the inlined content.
This is useful when your SVG images contain `` elements that
you do not want to bleed into the containing scope, and your Mkdocs
configuration includes extra CSS stylesheets that suffice.## Usage
To download and install this module, run:
```sh
pip install mkdocs-inline-select-svg-plugin
```Enable the plugin in your *mkdocs.yml* by adding `inline-select-svg` as a list item under the *plugins* section. Since that section will almost certainly include *search* you might end up with something like this:
```yaml
plugins:
- search
- inline-select-svg
```If you want to filter which SVGs to inline, by path, you can specify a regular expression using the *pattern* config option thus:
```yaml
plugins:
- search
- inline-select-svg:
pattern: "[.]inline[.]svg$"
```With that configuration, `<img src="../foo.inline.svg">` would be
inlined but `<img src="../foo.svg">` would not.[MkDocs plugin]: https://www.mkdocs.org/dev-guide/plugins/