Skip to main content

A plugin to quote file from docs

Project description

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-plugins
  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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_embed_file_plugins-2.0.9.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

mkdocs_embed_file_plugins-2.0.9-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_embed_file_plugins-2.0.9.tar.gz.

File metadata

File hashes

Hashes for mkdocs_embed_file_plugins-2.0.9.tar.gz
Algorithm Hash digest
SHA256 c75ec77094c61595b8b8e9dbc801488a8bc16046f8a08f51f27d83bc6540bb7b
MD5 8384267741f45ce2e39d3451741b310d
BLAKE2b-256 5ff01f9d11879a4f73f2a4a24f0a709a00b1c2c1734bdb587c69e2f2d77c9b2d

See more details on using hashes here.

File details

Details for the file mkdocs_embed_file_plugins-2.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_embed_file_plugins-2.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2a5efd9f60558a65a2a45ff54f810b0a97048d0f232c9c0be41c15f1b6f3c25e
MD5 74df53eb448d1c7a3758aa8aefaaf3ec
BLAKE2b-256 41c6c0bdce4339408ae288e726bf1ce9f26d9c885f9f883056d722e1ca1a909a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page