Render CLDF markdown in clld apps.
Project description
clld-markdown-plugin
Render CLDF markdown in clld apps
Usage
Include (and configure the plugin) in your app's main function:
def main(global_config, **settings):
settings['clld_markdown_plugin'] = {
'model_map': {'ValueTable': common.ValueSet},
'function_map': {}
}
config = Configurator(settings=settings)
config.include('clld.web.app')
...
config.include('clld_markdown_plugin')
Then you can use clld_markdown_plugin.markup as follows in your templates:
<%! from clld_markdown_plugin import markdown %>
${markdown(req, '[x](LanguageTable#cldf:abad1241)')|n}
By default, links to objects in the CLDF dataset will be rendered as HTML links to the corresponding object's details page in the clld app.
Configuration
The plugin can be configured via the following four configuration options:
model_map: Adictmapping CLDF component names to DB model classes defined for the app. This allows for a flexible mapping between CLDF components and the clld DB classes.renderer_map: See below for details.extensions: A list of markdown extensions in dot notation, to be activated when calling themarkdownfunction.keep_link_labels: Abooleanindicating whether to keep link labels as they appear in the CLDF Markdown text. By default (False), labels will be substituted using the linked object's name.
Renderer callables
The renderer_map configuration option for clld_markdown_plugin accepts a dict mapping
CLDF component names to Python callables with the following signature:
import clld.web.app
def renderer(req: clld.web.app.ClldRequest, objid: str, table, session: clld.db.meta.DBSession, ids=None) -> str:
"""
The returned `str` is interpreted as Markdown, so it may also include HTML.
"""
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clld_markdown_plugin-0.5.0.tar.gz.
File metadata
- Download URL: clld_markdown_plugin-0.5.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50af089a00cbfb0df6df06e710c950f1c5b6429b1a305ab63d13d4bc22465d2a
|
|
| MD5 |
a0073421b95fad18eb7eaea7731a8d33
|
|
| BLAKE2b-256 |
68bf98f8a88fd703744ec3ea2480d86730476d54eafdc42e599fdb9a60ca1062
|
File details
Details for the file clld_markdown_plugin-0.5.0-py3-none-any.whl.
File metadata
- Download URL: clld_markdown_plugin-0.5.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e04eee754837ab1193baf5e430ebc1c7deda36dd9baef653bb1f5fd4334a8128
|
|
| MD5 |
8fe8f4f70b842e0c8a1b16886300ca0b
|
|
| BLAKE2b-256 |
ca7621e52008b8c56fc77bef41a3a2b88e6a36a544a319df6bd58d18f6495c3e
|