clld-markdown-plugin 0.1.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clld_markdown_plugin-0.3.0/PKG-INFO +64 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/setup.cfg +7 -5
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin/__init__.py +25 -9
- clld_markdown_plugin-0.3.0/src/clld_markdown_plugin.egg-info/PKG-INFO +64 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin.egg-info/SOURCES.txt +2 -1
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin.egg-info/requires.txt +3 -3
- clld_markdown_plugin-0.3.0/tests/test_unit.py +31 -0
- clld_markdown_plugin-0.1.0/PKG-INFO +0 -65
- clld_markdown_plugin-0.1.0/src/clld_markdown_plugin.egg-info/PKG-INFO +0 -65
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/LICENSE +0 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/README.md +0 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/pyproject.toml +0 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/setup.py +0 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin.egg-info/dependency_links.txt +0 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin.egg-info/not-zip-safe +0 -0
- {clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: clld_markdown_plugin
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Render CLDF markdown in clld apps.
|
|
5
|
+
Home-page: https://github.com/clld/clld-markdown-plugin
|
|
6
|
+
Author: Robert Forkel, Florian Matter
|
|
7
|
+
Author-email: robert_forkel@eva.mpg.de, florianmatter@gmail.com
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/clld/clld-markdown-plugin/issues
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
|
|
24
|
+
# clld-markdown-plugin
|
|
25
|
+
|
|
26
|
+
Render CLDF markdown in clld apps
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Include (and configure the plugin) in your app's `main` function:
|
|
31
|
+
```python
|
|
32
|
+
def main(global_config, **settings):
|
|
33
|
+
settings['clld_markdown_plugin'] = {
|
|
34
|
+
'model_map': {'ValueTable': common.ValueSet},
|
|
35
|
+
'function_map': {}
|
|
36
|
+
}
|
|
37
|
+
config = Configurator(settings=settings)
|
|
38
|
+
config.include('clld.web.app')
|
|
39
|
+
...
|
|
40
|
+
config.include('clld_markdown_plugin')
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then you can use `clld_markdown_plugin.markup` as follows in your templates:
|
|
44
|
+
```html
|
|
45
|
+
<%! from clld_markdown_plugin import markdown %>
|
|
46
|
+
|
|
47
|
+
${markdown(req, '[x](LanguageTable#cldf:abad1241)')|n}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Renderer callables
|
|
52
|
+
|
|
53
|
+
The `renderer_map` configuration option for `clld_markdown_plugin` accepts a `dict` mapping
|
|
54
|
+
CLDF component names to Python callables with the following signature:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import clld.web.app
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def renderer(req: clld.web.app.ClldRequest, objid: str, table, session: clld.db.meta.DBSession, ids=None) -> str:
|
|
61
|
+
"""
|
|
62
|
+
The returned `str` is interpreted as Markdown, so it may also include HTML.
|
|
63
|
+
"""
|
|
64
|
+
```
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
author = Robert Forkel, Florian Matter
|
|
3
|
-
author_email =
|
|
3
|
+
author_email = robert_forkel@eva.mpg.de, florianmatter@gmail.com
|
|
4
4
|
classifiers =
|
|
5
5
|
Development Status :: 2 - Pre-Alpha
|
|
6
6
|
Intended Audience :: Science/Research
|
|
7
7
|
License :: OSI Approved :: Apache Software License
|
|
8
8
|
Natural Language :: English
|
|
9
9
|
Programming Language :: Python :: 3
|
|
10
|
-
Programming Language :: Python :: 3.7
|
|
11
10
|
Programming Language :: Python :: 3.8
|
|
12
11
|
Programming Language :: Python :: 3.9
|
|
13
12
|
Programming Language :: Python :: 3.10
|
|
14
13
|
Programming Language :: Python :: 3.11
|
|
14
|
+
Programming Language :: Python :: 3.12
|
|
15
15
|
description = Render CLDF markdown in clld apps.
|
|
16
16
|
long_description = file: README.md
|
|
17
17
|
long_description_content_type = text/markdown
|
|
@@ -19,7 +19,7 @@ name = clld_markdown_plugin
|
|
|
19
19
|
project_urls =
|
|
20
20
|
Bug Tracker = https://github.com/clld/clld-markdown-plugin/issues
|
|
21
21
|
url = https://github.com/clld/clld-markdown-plugin
|
|
22
|
-
version = 0.
|
|
22
|
+
version = 0.3.0
|
|
23
23
|
|
|
24
24
|
[options]
|
|
25
25
|
zip_safe = False
|
|
@@ -28,8 +28,8 @@ packages = find:
|
|
|
28
28
|
package_dir =
|
|
29
29
|
=src
|
|
30
30
|
install_requires =
|
|
31
|
+
pycldf
|
|
31
32
|
clld
|
|
32
|
-
cldfviz
|
|
33
33
|
markdown
|
|
34
34
|
|
|
35
35
|
[options.extras_require]
|
|
@@ -55,6 +55,8 @@ extend-ignore = E203
|
|
|
55
55
|
[tool:pytest]
|
|
56
56
|
addopts = --cov
|
|
57
57
|
testpaths = tests
|
|
58
|
+
filterwarnings =
|
|
59
|
+
ignore::sqlalchemy.exc.RemovedIn20Warning
|
|
58
60
|
|
|
59
61
|
[coverage:run]
|
|
60
62
|
source =
|
|
@@ -64,7 +66,7 @@ source =
|
|
|
64
66
|
show_missing = true
|
|
65
67
|
|
|
66
68
|
[tox:tox]
|
|
67
|
-
envlist =
|
|
69
|
+
envlist = py38, py39, py310, py311, py312
|
|
68
70
|
isolated_build = true
|
|
69
71
|
skip_missing_interpreter = true
|
|
70
72
|
|
{clld_markdown_plugin-0.1.0 → clld_markdown_plugin-0.3.0}/src/clld_markdown_plugin/__init__.py
RENAMED
|
@@ -3,16 +3,17 @@ import typing
|
|
|
3
3
|
import logging
|
|
4
4
|
|
|
5
5
|
from markdown import Markdown
|
|
6
|
-
from
|
|
6
|
+
from pycldf.ext.markdown import CLDFMarkdownLink
|
|
7
7
|
from clld.db.meta import DBSession
|
|
8
8
|
from clld.db.models import common
|
|
9
9
|
from clld.web.util.helpers import rendered_sentence
|
|
10
|
+
from clld.web.util.htmllib import HTML, literal
|
|
10
11
|
|
|
11
12
|
log = logging.getLogger(__name__)
|
|
12
13
|
|
|
13
14
|
__author__ = "Robert Forkel, Florian Matter"
|
|
14
15
|
__email__ = "robert_forkel@eva.mpg.de, florianmatter@gmail.com"
|
|
15
|
-
__version__ = "0.
|
|
16
|
+
__version__ = "0.3.0"
|
|
16
17
|
__all__ = ['markdown', 'includeme']
|
|
17
18
|
|
|
18
19
|
|
|
@@ -82,18 +83,21 @@ def link_entity(req, objid, route, model, session, decorate=None, ids=None, **kw
|
|
|
82
83
|
if objid == "__all__":
|
|
83
84
|
if ids:
|
|
84
85
|
md_strs = [
|
|
85
|
-
link_entity(req, mid, route, model, session, decorate=decorate)
|
|
86
|
+
link_entity(req, mid, route, model, session, decorate=decorate, **kwargs)
|
|
86
87
|
for mid in ids[0].split(",")
|
|
87
88
|
]
|
|
88
89
|
return comma_and_list(md_strs)
|
|
89
90
|
raise NotImplementedError("Table not yet implemented") # pragma: no cover
|
|
90
91
|
else:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
try:
|
|
93
|
+
entity = session.query(model).filter(model.id == objid)[0]
|
|
94
|
+
except IndexError:
|
|
95
|
+
raise ValueError(objid) # pragma: no cover
|
|
96
|
+
label = kwargs.pop("label", [None])[0]
|
|
97
|
+
anchor = kwargs.pop("_anchor", [None])[0]
|
|
95
98
|
url = req.route_url(route, id=objid, _anchor=anchor, **kwargs)
|
|
96
|
-
md_str =
|
|
99
|
+
md_str = '<a class="{}" href="{}">{}</a>'.format(
|
|
100
|
+
model.__tablename__.capitalize(), url, label or entity.name)
|
|
97
101
|
return decorate(md_str) if decorate else md_str
|
|
98
102
|
|
|
99
103
|
|
|
@@ -120,6 +124,7 @@ def markdown(req, s: str, session=None) -> str:
|
|
|
120
124
|
'{} must be included in the app config to use the "markdown" function.'.format(
|
|
121
125
|
__name__))
|
|
122
126
|
settings = req.registry.settings[__name__]
|
|
127
|
+
source_ids = set()
|
|
123
128
|
|
|
124
129
|
def repl(ml):
|
|
125
130
|
if ml.is_cldf_link:
|
|
@@ -130,6 +135,17 @@ def markdown(req, s: str, session=None) -> str:
|
|
|
130
135
|
req, ml.objid, table, session or DBSession, **ml.parsed_url_query)
|
|
131
136
|
elif table in settings['model_map']:
|
|
132
137
|
decorate = settings['model_map'][table].get("decorate", None)
|
|
138
|
+
kw = {k: v for k, v in ml.parsed_url_query.items()}
|
|
139
|
+
if table == 'Source':
|
|
140
|
+
if ml.objid != '__all__':
|
|
141
|
+
source_ids.add(ml.objid)
|
|
142
|
+
elif 'cited_only' in ml.parsed_url.query:
|
|
143
|
+
model = settings['model_map'][table]["model"]
|
|
144
|
+
return HTML.ul(*[
|
|
145
|
+
HTML.li(literal(
|
|
146
|
+
(session or DBSession).query(model)
|
|
147
|
+
.filter(model.id == sid)[0].bibtex().text()))
|
|
148
|
+
for sid in sorted(source_ids)])
|
|
133
149
|
return link_entity(
|
|
134
150
|
req,
|
|
135
151
|
ml.objid,
|
|
@@ -137,7 +153,7 @@ def markdown(req, s: str, session=None) -> str:
|
|
|
137
153
|
settings['model_map'][table]["model"],
|
|
138
154
|
session or DBSession,
|
|
139
155
|
decorate=decorate,
|
|
140
|
-
**
|
|
156
|
+
**kw,
|
|
141
157
|
)
|
|
142
158
|
log.error(f"Can't handle [{ml.objid}] ({table}).")
|
|
143
159
|
return f"{table}:{ml.objid}"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: clld-markdown-plugin
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Render CLDF markdown in clld apps.
|
|
5
|
+
Home-page: https://github.com/clld/clld-markdown-plugin
|
|
6
|
+
Author: Robert Forkel, Florian Matter
|
|
7
|
+
Author-email: robert_forkel@eva.mpg.de, florianmatter@gmail.com
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/clld/clld-markdown-plugin/issues
|
|
9
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
|
|
24
|
+
# clld-markdown-plugin
|
|
25
|
+
|
|
26
|
+
Render CLDF markdown in clld apps
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
Include (and configure the plugin) in your app's `main` function:
|
|
31
|
+
```python
|
|
32
|
+
def main(global_config, **settings):
|
|
33
|
+
settings['clld_markdown_plugin'] = {
|
|
34
|
+
'model_map': {'ValueTable': common.ValueSet},
|
|
35
|
+
'function_map': {}
|
|
36
|
+
}
|
|
37
|
+
config = Configurator(settings=settings)
|
|
38
|
+
config.include('clld.web.app')
|
|
39
|
+
...
|
|
40
|
+
config.include('clld_markdown_plugin')
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then you can use `clld_markdown_plugin.markup` as follows in your templates:
|
|
44
|
+
```html
|
|
45
|
+
<%! from clld_markdown_plugin import markdown %>
|
|
46
|
+
|
|
47
|
+
${markdown(req, '[x](LanguageTable#cldf:abad1241)')|n}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Renderer callables
|
|
52
|
+
|
|
53
|
+
The `renderer_map` configuration option for `clld_markdown_plugin` accepts a `dict` mapping
|
|
54
|
+
CLDF component names to Python callables with the following signature:
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
import clld.web.app
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def renderer(req: clld.web.app.ClldRequest, objid: str, table, session: clld.db.meta.DBSession, ids=None) -> str:
|
|
61
|
+
"""
|
|
62
|
+
The returned `str` is interpreted as Markdown, so it may also include HTML.
|
|
63
|
+
"""
|
|
64
|
+
```
|
|
@@ -9,4 +9,5 @@ src/clld_markdown_plugin.egg-info/SOURCES.txt
|
|
|
9
9
|
src/clld_markdown_plugin.egg-info/dependency_links.txt
|
|
10
10
|
src/clld_markdown_plugin.egg-info/not-zip-safe
|
|
11
11
|
src/clld_markdown_plugin.egg-info/requires.txt
|
|
12
|
-
src/clld_markdown_plugin.egg-info/top_level.txt
|
|
12
|
+
src/clld_markdown_plugin.egg-info/top_level.txt
|
|
13
|
+
tests/test_unit.py
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from clld_markdown_plugin import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.parametrize(
|
|
7
|
+
'model_map,renderer_map,md,substring,notsubstring',
|
|
8
|
+
[
|
|
9
|
+
(dict(LanguageTable=None), {}, '[xyz](LanguageTable#cldf:l1)', 'xyz', None),
|
|
10
|
+
({}, {}, '[xyz](LanguageTable#cldf:l1)', 'The Language', None),
|
|
11
|
+
({}, {}, '[xyz](LanguageTable?_anchor=abc#cldf:l1)', '#abc', None),
|
|
12
|
+
({}, {}, '[xyz](LanguageTable?ids=l1,l2,l3#cldf:__all__)', ' and ', None),
|
|
13
|
+
({}, {}, '[xyz](ExampleTable#cldf:s1)', 'A sentence', None),
|
|
14
|
+
({}, {}, '[xyz](ExampleTable?as_link#cldf:s1)', 'href=', None),
|
|
15
|
+
({}, {}, '[xyz](ExampleTable?ids=s1#cldf:__all__)', '', None),
|
|
16
|
+
({}, {}, '[xyz](NopeTable#cldf:1)', 'NopeTable', None),
|
|
17
|
+
(
|
|
18
|
+
{},
|
|
19
|
+
{},
|
|
20
|
+
'[](Source#cldf:Meier2012)\n[](Source?cited_only#cldf:__all__)',
|
|
21
|
+
'Meier',
|
|
22
|
+
'Mueller'),
|
|
23
|
+
({}, {}, '[xyz](http://example.org)', 'http://example.org', None),
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
def test_markdown(model_map, renderer_map, md, substring, notsubstring, dbsession, req_factory):
|
|
27
|
+
res = markdown(
|
|
28
|
+
req_factory(dict(model_map=model_map, renderer_map=renderer_map)), md, session=dbsession)
|
|
29
|
+
assert substring in res
|
|
30
|
+
if notsubstring:
|
|
31
|
+
assert notsubstring not in res
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: clld_markdown_plugin
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Render CLDF markdown in clld apps.
|
|
5
|
-
Home-page: https://github.com/clld/clld-markdown-plugin
|
|
6
|
-
Author: Robert Forkel, Florian Matter
|
|
7
|
-
Author-email: forkel@shh.mpg.de, florianmatter@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Project-URL: Bug Tracker, https://github.com/clld/clld-markdown-plugin/issues
|
|
10
|
-
Description: # clld-markdown-plugin
|
|
11
|
-
|
|
12
|
-
Render CLDF markdown in clld apps
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
Include (and configure the plugin) in your app's `main` function:
|
|
17
|
-
```python
|
|
18
|
-
def main(global_config, **settings):
|
|
19
|
-
settings['clld_markdown_plugin'] = {
|
|
20
|
-
'model_map': {'ValueTable': common.ValueSet},
|
|
21
|
-
'function_map': {}
|
|
22
|
-
}
|
|
23
|
-
config = Configurator(settings=settings)
|
|
24
|
-
config.include('clld.web.app')
|
|
25
|
-
...
|
|
26
|
-
config.include('clld_markdown_plugin')
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Then you can use `clld_markdown_plugin.markup` as follows in your templates:
|
|
30
|
-
```html
|
|
31
|
-
<%! from clld_markdown_plugin import markdown %>
|
|
32
|
-
|
|
33
|
-
${markdown(req, '[x](LanguageTable#cldf:abad1241)')|n}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### Renderer callables
|
|
38
|
-
|
|
39
|
-
The `renderer_map` configuration option for `clld_markdown_plugin` accepts a `dict` mapping
|
|
40
|
-
CLDF component names to Python callables with the following signature:
|
|
41
|
-
|
|
42
|
-
```python
|
|
43
|
-
import clld.web.app
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def renderer(req: clld.web.app.ClldRequest, objid: str, table, session: clld.db.meta.DBSession, ids=None) -> str:
|
|
47
|
-
"""
|
|
48
|
-
The returned `str` is interpreted as Markdown, so it may also include HTML.
|
|
49
|
-
"""
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Platform: UNKNOWN
|
|
53
|
-
Classifier: Development Status :: 2 - Pre-Alpha
|
|
54
|
-
Classifier: Intended Audience :: Science/Research
|
|
55
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
56
|
-
Classifier: Natural Language :: English
|
|
57
|
-
Classifier: Programming Language :: Python :: 3
|
|
58
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
59
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
60
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
61
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
62
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
63
|
-
Description-Content-Type: text/markdown
|
|
64
|
-
Provides-Extra: dev
|
|
65
|
-
Provides-Extra: test
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: clld-markdown-plugin
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Render CLDF markdown in clld apps.
|
|
5
|
-
Home-page: https://github.com/clld/clld-markdown-plugin
|
|
6
|
-
Author: Robert Forkel, Florian Matter
|
|
7
|
-
Author-email: forkel@shh.mpg.de, florianmatter@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Project-URL: Bug Tracker, https://github.com/clld/clld-markdown-plugin/issues
|
|
10
|
-
Description: # clld-markdown-plugin
|
|
11
|
-
|
|
12
|
-
Render CLDF markdown in clld apps
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
Include (and configure the plugin) in your app's `main` function:
|
|
17
|
-
```python
|
|
18
|
-
def main(global_config, **settings):
|
|
19
|
-
settings['clld_markdown_plugin'] = {
|
|
20
|
-
'model_map': {'ValueTable': common.ValueSet},
|
|
21
|
-
'function_map': {}
|
|
22
|
-
}
|
|
23
|
-
config = Configurator(settings=settings)
|
|
24
|
-
config.include('clld.web.app')
|
|
25
|
-
...
|
|
26
|
-
config.include('clld_markdown_plugin')
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Then you can use `clld_markdown_plugin.markup` as follows in your templates:
|
|
30
|
-
```html
|
|
31
|
-
<%! from clld_markdown_plugin import markdown %>
|
|
32
|
-
|
|
33
|
-
${markdown(req, '[x](LanguageTable#cldf:abad1241)')|n}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### Renderer callables
|
|
38
|
-
|
|
39
|
-
The `renderer_map` configuration option for `clld_markdown_plugin` accepts a `dict` mapping
|
|
40
|
-
CLDF component names to Python callables with the following signature:
|
|
41
|
-
|
|
42
|
-
```python
|
|
43
|
-
import clld.web.app
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def renderer(req: clld.web.app.ClldRequest, objid: str, table, session: clld.db.meta.DBSession, ids=None) -> str:
|
|
47
|
-
"""
|
|
48
|
-
The returned `str` is interpreted as Markdown, so it may also include HTML.
|
|
49
|
-
"""
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Platform: UNKNOWN
|
|
53
|
-
Classifier: Development Status :: 2 - Pre-Alpha
|
|
54
|
-
Classifier: Intended Audience :: Science/Research
|
|
55
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
56
|
-
Classifier: Natural Language :: English
|
|
57
|
-
Classifier: Programming Language :: Python :: 3
|
|
58
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
59
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
60
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
61
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
62
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
63
|
-
Description-Content-Type: text/markdown
|
|
64
|
-
Provides-Extra: dev
|
|
65
|
-
Provides-Extra: test
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|