# Embed File
A way to embed a file present in your docs.
Support both wikilinks & normal links.
Intended to be used by obsidian user.


# Activate the plugin
1. Run `pip install mkdocs-embed-file-plugin`
2. Update your `mkdocs.yml` with :
```yaml
plugins:
- search
- embed_file
```
3. [Override](https://www.mkdocs.org/user-guide/customizing-your-theme/) your `main.html` with :
```html
{% extends "base.html" %}
{% block extrahead %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/fontawesome.min.css" integrity="sha384-jLKHWM3JRmfMU0A5x5AkjWkw/EYfGUAGagvnfryNV3F9VqM98XiIH7VBGVoxVSc7" crossorigin="anonymous">
{% endblock %}
```
> [!IMPORTANT]
> You need to set the `site_url` in the `mkdocs.yml` to make the plugin work.
# Usage
| Usage | wikilinks | markdown links |
|---------------------|--------------------------|--------------------------|
| cite a entire file | `![[filename]] ` | ` ` |
| Cite a heading part | `![[filename#heading]] ` | `` |
| Cite a block | `![[filename#^blockid]]` | `` |
# CSS
The plugin will create :
- A link to the original file, with the form of : `<a href="original link" class="link_citation"><i class='fas fa-link'></i></a>`
- A div with the founded content : `<div class="citation">content founded</div>`
- In case of the link / contents is not found the following block is created instead :
```html
<div class='citation'><a class='link_citation'><i class='fas fa-link'></i></a><p style="text-align: center; display: block"><i class="not_found"> link_alt </i> {a configured message}</p></div>
```
The message for the not found file can be customized in `mkdocs.yml`. The default message is `file not exists`.
You can add a css in your `docs/assets/css` (or whatever the path is), and add it to your `mkdocs.yml` :
```yml
extra_css:
- assets/css/embed_link.css
```
You can find an example of custom css in [docs](docs/embed_link.css)
# Configuration
If you want, you can add compatibility with :
- [mkdocs callouts](https://github.com/sondregronas/mkdocs-callouts)
- [mkdocs custom tags attributes](https://github.com/Mara-Li/mkdocs-custom-tags-attributes)
To do that, adjust your `mkdocs.yml`
```yaml
markdown_extensions:
- attr_list
- nl2br
- admonition
- pymdownx.details
plugins:
- search
- callouts
- custom-attributes:
file: 'assets/css/custom_attributes.css'
- embed_file:
callouts: true
custom-attribute: 'assets/css/custom_attributes.css' //need to be the same as in the config!
language_message: 'file not exists.'
```
Note : Every extension set in `markdown_extensions` will be used for the converting, so you can use any extension you want.
# Limitation
- The embed file don't use plugin you would use.
- Wikilinks ambiguity are not supported : the first file with the name are used.
# Credit
Thanks to [midnightprioriem](https://github.com/midnightprioriem/mkdocs-tooltipster-links-plugin) for the tooltip plugin.
Raw data
{
"_id": null,
"home_page": null,
"name": "mkdocs-embed-file-plugin",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.13",
"maintainer_email": null,
"keywords": "cite, embed, file, mkdocs, obsidian, obsidian.md, quote",
"author": null,
"author_email": "Mara-Li <mara-li@outlook.fr>",
"download_url": "https://files.pythonhosted.org/packages/73/0d/80cc1a2d461c89f7edb2450227368cb04b0c0f0ec577996dd19c8c837a1d/mkdocs_embed_file_plugin-2.1.4.tar.gz",
"platform": null,
"description": "# Embed File\nA way to embed a file present in your docs.\nSupport both wikilinks & normal links.\nIntended to be used by obsidian user.\n\n\n\n\n# Activate the plugin\n1. Run `pip install mkdocs-embed-file-plugin`\n2. Update your `mkdocs.yml` with :\n ```yaml\n plugins:\n - search\n - embed_file\n ```\n3. [Override](https://www.mkdocs.org/user-guide/customizing-your-theme/) your `main.html` with :\n ```html\n {% extends \"base.html\" %}\n {% block extrahead %}\n\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/css/fontawesome.min.css\" integrity=\"sha384-jLKHWM3JRmfMU0A5x5AkjWkw/EYfGUAGagvnfryNV3F9VqM98XiIH7VBGVoxVSc7\" crossorigin=\"anonymous\">\n {% endblock %}\n ```\n\n> [!IMPORTANT]\n> You need to set the `site_url` in the `mkdocs.yml` to make the plugin work.\n\n# Usage\n\n| Usage | wikilinks | markdown links |\n|---------------------|--------------------------|--------------------------|\n| cite a entire file | `![[filename]] ` | ` ` |\n| Cite a heading part | `![[filename#heading]] ` | `` |\n| Cite a block | `![[filename#^blockid]]` | `` |\n\n# CSS\n\nThe plugin will create :\n- A link to the original file, with the form of : `<a href=\"original link\" class=\"link_citation\"><i class='fas fa-link'></i></a>`\n- A div with the founded content : `<div class=\"citation\">content founded</div>`\n- In case of the link / contents is not found the following block is created instead :\n ```html\n <div class='citation'><a class='link_citation'><i class='fas fa-link'></i></a><p style=\"text-align: center; display: block\"><i class=\"not_found\"> link_alt </i> {a configured message}</p></div>\n ```\n The message for the not found file can be customized in `mkdocs.yml`. The default message is `file not exists`.\n\nYou can add a css in your `docs/assets/css` (or whatever the path is), and add it to your `mkdocs.yml` :\n```yml\nextra_css:\n - assets/css/embed_link.css\n```\nYou can find an example of custom css in [docs](docs/embed_link.css)\n\n# Configuration\nIf you want, you can add compatibility with :\n- [mkdocs callouts](https://github.com/sondregronas/mkdocs-callouts)\n- [mkdocs custom tags attributes](https://github.com/Mara-Li/mkdocs-custom-tags-attributes)\n\nTo do that, adjust your `mkdocs.yml`\n```yaml\nmarkdown_extensions:\n - attr_list\n - nl2br\n - admonition\n - pymdownx.details\nplugins:\n - search\n - callouts\n - custom-attributes:\n file: 'assets/css/custom_attributes.css'\n - embed_file:\n callouts: true\n custom-attribute: 'assets/css/custom_attributes.css' //need to be the same as in the config!\n language_message: 'file not exists.'\n```\n\nNote : Every extension set in `markdown_extensions` will be used for the converting, so you can use any extension you want.\n\n# Limitation\n- The embed file don't use plugin you would use.\n- Wikilinks ambiguity are not supported : the first file with the name are used.\n\n# Credit\nThanks to [midnightprioriem](https://github.com/midnightprioriem/mkdocs-tooltipster-links-plugin) for the tooltip plugin.\n",
"bugtrack_url": null,
"license": null,
"summary": "A plugin to quote file from docs",
"version": "2.1.4",
"project_urls": {
"homepage": "https://github.com/ObsidianPublisher/mkdocs-embed_file-plugin"
},
"split_keywords": [
"cite",
" embed",
" file",
" mkdocs",
" obsidian",
" obsidian.md",
" quote"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "e88dea2ecec42c6c49c3c33493906a8640da690fad0bde48cd7fcba821c93ab9",
"md5": "6bf15a6ead5d75caee4d02fea32a1c60",
"sha256": "983c368d4a4222f9d317f68fa45ac8a7df2c97f62d815a0188af46885b1b17ae"
},
"downloads": -1,
"filename": "mkdocs_embed_file_plugin-2.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6bf15a6ead5d75caee4d02fea32a1c60",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.13",
"size": 21811,
"upload_time": "2025-02-07T05:31:58",
"upload_time_iso_8601": "2025-02-07T05:31:58.467939Z",
"url": "https://files.pythonhosted.org/packages/e8/8d/ea2ecec42c6c49c3c33493906a8640da690fad0bde48cd7fcba821c93ab9/mkdocs_embed_file_plugin-2.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "730d80cc1a2d461c89f7edb2450227368cb04b0c0f0ec577996dd19c8c837a1d",
"md5": "a8838023a01d5a6c1891b5552cb41e8d",
"sha256": "bd2fdfd08212079e5f36bb5c880683d0de24c8c541bd27d71d32b1edcc8d04cf"
},
"downloads": -1,
"filename": "mkdocs_embed_file_plugin-2.1.4.tar.gz",
"has_sig": false,
"md5_digest": "a8838023a01d5a6c1891b5552cb41e8d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.13",
"size": 1642856,
"upload_time": "2025-02-07T05:32:01",
"upload_time_iso_8601": "2025-02-07T05:32:01.390209Z",
"url": "https://files.pythonhosted.org/packages/73/0d/80cc1a2d461c89f7edb2450227368cb04b0c0f0ec577996dd19c8c837a1d/mkdocs_embed_file_plugin-2.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-07 05:32:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ObsidianPublisher",
"github_project": "mkdocs-embed_file-plugin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mkdocs-embed-file-plugin"
}