Create a page that contains all of your listings and/or a search function for listings
Project description
mkdocs-extract-listings-plugin
A small plugin to extract all your listings and put them in a single page. It can also generate a search function of code listings with different search methods (fuzzy match, substring, contains words).
Setup
-
Install the plugin using pip:
pip install mkdocs-extract-listings-plugin
-
Add the plugin to your
mkdocs.yml
:plugins: - search - extract_listings
If you have no
plugins
entry in your config file yet, you'll likely also want to add thesearch
plugin. MkDocs enables it by default if there is noplugins
entry set.More information about plugins in the MkDocs documentation.
-
Configure a page with all listings, a page with listing search, or both (see below).
Listing page
Add a Markdown file for the page that will be filled with all the listings.
In that file add the placeholder where the listings should be inserted.
Then reference that file and specify the placeholder like this in your mkdocs.yml
:
plugins:
- extract_listings:
listings_file: listings.md
placeholder: PLACEHOLDER_LISTINGS_PLUGIN
Listing search
-
Create a page, which should contain the search function.
-
Add a tag where the search elements should be inserted and load the search script:
<div id="listing-extract-search"></div> <script src="/listing-search.js">
-
Specify where you want the plugin to write the script file to. This should match the path you used in the previous step. In
mkdocs.yml
:plugins: - extract_listings: javascript_search_file: listing-search.js
Configuration
You can configure the plugin like this:
plugins:
- extract_listings:
listings_file: listings.md
placeholder: PLACEHOLDER_LISTINGS_PLUGIN
javascript_search_file: listing-search.js
listings_file
listings_file
is expected to contain the relative path to the Markdown file, where the listings should be written to.
If the file does not exist, an error will be raised during the build process.
The default value is empty.
placeholder
The value for placeholder
will be searched in the file referenced by listings_file
and be replaced with the list of all listings.
javascript_search_file
The JavaScript code for the search function will be written to this path. The default value is empty, meaning that neither the JSOn file nor the JavaScript are generated.
Changelog
Version 0.0.3
- Added snippet search JavaScript and JSON file.
- Changed default for
listings_file
to empty string.
Version 0.0.2
- Fixed
Unknown path
being shown on with different themes (readthedocs
andmaterial
)
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
Built Distribution
Hashes for mkdocs-extract-listings-plugin-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99559b5a9c9588b7f8c69c0f0ff6710e603668169bd91b94b3334e991730a187 |
|
MD5 | e0bd7c8efddbfcade007dd67a624d561 |
|
BLAKE2b-256 | 0ea23567917e1b082914964e348b0cd6dac1a3c1a1a8ecd91544cda98ee7c86d |
Hashes for mkdocs_extract_listings_plugin-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02054c77b6f47ffd3a937d2132149988ec89994052205b0bb1a0225008714733 |
|
MD5 | 076d4a777e376d4fc4a81a4ce193c06b |
|
BLAKE2b-256 | d7eac36f8c9391ad7fe882ec9eeabe1a04e980a6a177ac42cc6ae08cfe29fb7d |