# Embed File
A way to embed a file present in your docs.
Support both wikilinks & normal links.
Intended to be used by obsidian user.
![](docs/note3.png)
![](docs/demo.gif)
# Activate the plugin
1. Run `pip install mkdocs-embed-file-plugins`
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]] ` | `![](filename) ` |
| Cite a heading part | `![[filename#heading]] ` | `![](filename#heading)` |
| Cite a block | `![[filename#^blockid]]` | `![](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/77/1b/e877d7a1a5650e563ed7c2b94337888cb82ece6ab5f85303b54ec16b4679/mkdocs_embed_file_plugin-2.1.3.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![](docs/note3.png)\n![](docs/demo.gif)\n\n# Activate the plugin\n1. Run `pip install mkdocs-embed-file-plugins`\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]] ` | `![](filename) ` |\n| Cite a heading part | `![[filename#heading]] ` | `![](filename#heading)` |\n| Cite a block | `![[filename#^blockid]]` | `![](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.3",
"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": "4bf9818e5d8aabd62053803c566c3ae70f6956266fdd778c3871178d97fef0e3",
"md5": "4a212053e33dc6ebbd6bce385e0291bf",
"sha256": "39aa7f12d027a29277689eff967c17b562d0720b3bae34fe66cade10ad9ccd3d"
},
"downloads": -1,
"filename": "mkdocs_embed_file_plugin-2.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4a212053e33dc6ebbd6bce385e0291bf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.13",
"size": 21808,
"upload_time": "2024-12-24T19:13:47",
"upload_time_iso_8601": "2024-12-24T19:13:47.723133Z",
"url": "https://files.pythonhosted.org/packages/4b/f9/818e5d8aabd62053803c566c3ae70f6956266fdd778c3871178d97fef0e3/mkdocs_embed_file_plugin-2.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "771be877d7a1a5650e563ed7c2b94337888cb82ece6ab5f85303b54ec16b4679",
"md5": "84cdd65fdf6a40710bef952d987db84f",
"sha256": "e7d4483ccbd88f5aa1a993bede058c17aa8bd66ec9d8a62266162cc8e96cb657"
},
"downloads": -1,
"filename": "mkdocs_embed_file_plugin-2.1.3.tar.gz",
"has_sig": false,
"md5_digest": "84cdd65fdf6a40710bef952d987db84f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.13",
"size": 1622648,
"upload_time": "2024-12-24T19:13:50",
"upload_time_iso_8601": "2024-12-24T19:13:50.947371Z",
"url": "https://files.pythonhosted.org/packages/77/1b/e877d7a1a5650e563ed7c2b94337888cb82ece6ab5f85303b54ec16b4679/mkdocs_embed_file_plugin-2.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-24 19:13:50",
"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"
}