Skip to main content

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 :
    plugins:
      - search
      - embed_file
    
  3. Override your main.html with :
    {% 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 :
    <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 :

extra_css:
    - assets/css/embed_link.css

You can find an example of custom css in docs

Configuration

If you want, you can add compatibility with :

To do that, adjust your mkdocs.yml

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 for the tooltip plugin.

Metadata

Release files for mkdocs-embed-file-plugin 2.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-embed-file-plugin 2.1.4
File Size Uploaded
mkdocs_embed_file_plugin-2.1.4.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-embed-file-plugin 2.1.4
File Interpreter ABI Platform
mkdocs_embed_file_plugin-2.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 1.7 MB

Release files / mkdocs_embed_file_plugin-2.1.4.tar.gz

Download URL mkdocs_embed_file_plugin-2.1.4.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
bd2fdfd08212079e5f36bb5c880683d0de24c8c541bd27d71d32b1edcc8d04cf
BLAKE2b-256 checksum
How to use checksums
730d80cc1a2d461c89f7edb2450227368cb04b0c0f0ec577996dd19c8c837a1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.26

Release files / mkdocs_embed_file_plugin-2.1.4-py3-none-any.whl

Download URL mkdocs_embed_file_plugin-2.1.4-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
983c368d4a4222f9d317f68fa45ac8a7df2c97f62d815a0188af46885b1b17ae
BLAKE2b-256 checksum
How to use checksums
e88dea2ecec42c6c49c3c33493906a8640da690fad0bde48cd7fcba821c93ab9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.26

Release history Release notifications | RSS feed

This release

2.1.4 This release

2 release files

2.1.3

2 release files

2.0.12

2 release files

2.0.11

2 release files

2.0.10

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page