From e2ab4c9489c2392cc2f718eb2b688e791309fa88 Mon Sep 17 00:00:00 2001
From: David Sillman Welcome to my MR. Some of the changes are listed below: In addition to the changes above, there are also a few breaking changes introduced in this MR: For more information, please check out the Jira ticket associated with this MR, IGDP-13. Welcome to my MR. Some of the changes are listed below: In addition to the changes above, there are also a few breaking changes introduced in this MR: For more information, please check out the Jira ticket associated with this MR, IGDP-13. The root of your project is expected to have a The The For more information, please check out the Jira ticket associated with this MR, IGDP-13. Because the Because the Author: This is a very simple MR format which can easily be generalized to allow for quickly generating large sets of docs which
meet the same format and style requirements. An example content schematic which could service this template could
be in In the Jinja templating context which is loaded for each templated document, there are a handful of helpful Jinja macros
+and filters which can be used to make formatting content easier. The macros and filters are segregated into
+3 namespaces, documented below: The global namespace contains helpful macros and filters for manipulating data in the Jinja
+context. It also provides access to more specific namespaces through their respective identifiers,
+such as None None Author: This is a paragraph. And a block quote.[IGDP-13] Adding software version as hard requirement for staging
+
+
+
+
+
+
+ [IGDP-13] Adding software version as hard requirement for staging
-
-
-
-
-
-
- Quick Intro
.metadock
folder, which can be generated from the CLI using
metadock init
.Basic CLI Usage
-metadock
CLI, installed using pip install metadock
, has 5 basic commands, spelled out in the help message:metadock
CLI, installed using pip install metadock
, has 5 basic commands,
+spelled out in the help message:usage: metadock [-h] [-p PROJECT_DIR] {init,validate,build,list,clean} ...
Generates and formats Jinja documentation templates from yaml sources.
@@ -100,7 +101,7 @@
Basic CLI Usage
metadock.Metadock.list
(list[str], list[str]) -> metadock.engine.MetadockProjectListResult
(list[str], list[str]) -> list[str]
[IGDP-13] Adding software version as hard requirement for staging
target_formats
we chose included md+html
and md
, we also get an HTML rendering of the document for free,
-located at generated_documents/gitlab_mr__feature_1.html
:target_formats
we chose included md+html
and md
, we also get an HTML rendering of the document for
+free, located at generated_documents/gitlab_mr__feature_1.html
:<h1>[IGDP-13] Adding software version as hard requirement for staging</h1>
<p>Welcome to my MR. Some of the changes are listed below:</p>
<ol>
@@ -237,9 +238,12 @@
[IGDP-13] Adding software version as hard requirement for staging
txt
, sql
or py
.txt
, .sql
or
-.py
.txt
, sql
or py
:
+
+.txt
, .sql
or .py
.Acknowledgements
metadock.Metadock.list
(list[str], list[str]) -> metadock.engine.MetadockProjectListResult
(list[str], list[str]) -> list[str]
[IGDP-13] Adding software version as hard requirement for staging
@@ -266,9 +266,9 @@ The natively supported values for `target_formats` are:
- `md+html`:
- Generates the given template, parses it into a markdown document, and then generates HTML from it.
-- Anything else, e.g. `txt`, `sql` or `py`
-- Generates the given template as plaintext, and adds the given string as a file extension, e.g. `.txt`, `.sql` or
- `.py`.
+- Anything else, e.g. `txt`, `sql` or `py`:
+ - Generates the given template as plaintext, and adds the given string as a file extension, e.g.
+ `.txt`, `.sql` or `.py`.
## Acknowledgements
diff --git a/.metadock/templated_documents/repo_readme_template.md b/.metadock/templated_documents/repo_readme_template.md
index a632d22..8c1bebf 100644
--- a/.metadock/templated_documents/repo_readme_template.md
+++ b/.metadock/templated_documents/repo_readme_template.md
@@ -18,7 +18,8 @@ The root of your project is expected to have a `.metadock` folder, which can be
## Basic CLI Usage
-The `metadock` CLI, installed using `pip install metadock`, has {{ cli.get("commands") | length }} basic commands, spelled out in the help message:
+The `metadock` CLI, installed using `pip install metadock`, has {{ cli.get("commands") | length }} basic commands,
+spelled out in the help message:
{{ md.codeblock(cli.get("usage_string"), language="sh") }}
@@ -50,7 +51,6 @@ In the example above, we can imagine the content of our template, `gitlab_mr_tem
This is a very simple MR format which can easily be generalized to allow for quickly generating large sets of docs which
meet the same format and style requirements. An example *content schematic* which could service this template could
be in `gitlab_mr__feature1.yml`:
-
{{
md.codeblock(
example_project.get("content_schematics").get("gitlab_mr__feature1.yml"),
@@ -63,8 +63,8 @@ called `generated_documents/gitlab_mr__feature1.md`:
{{ md.blockquote(example_project.get("generated_documents").get("gitlab_mr__feature1.md")) }}
-Because the `target_formats` we chose included `md+html` _and_ `md`, we also get an HTML rendering of the document for free,
-located at `generated_documents/gitlab_mr__feature_1.html`:
+Because the `target_formats` we chose included `md+html` _and_ `md`, we also get an HTML rendering of the document for
+free, located at `generated_documents/gitlab_mr__feature_1.html`:
{{
md.codeblock(
@@ -84,16 +84,12 @@ The natively supported values for `target_formats` are:
{% for target_format, data in target_formats.items() %}
{{ md.list(md.code(target_format) ~ ":", md.list(data.get("description"))) }}
{% endfor -%}
-{{
- md.list(
- "Anything else, e.g. `txt`, `sql` or `py`",
- "Generates the given template as plaintext, and adds the given string as a file extension, e.g. `.txt`, `.sql` or
- `.py`."
- )
-}}
+- Anything else, e.g. `txt`, `sql` or `py`:
+ - Generates the given template as plaintext, and adds the given string as a file extension, e.g.
+ `.txt`, `.sql` or `.py`.
## Acknowledgements
Author{% if (authors | length) > 1 %}s{% endif %}:
-{{ md.list(*authors) }}
\ No newline at end of file
+{{ authors | md.list }}
\ No newline at end of file
diff --git a/README.md b/README.md
index 1bf7f9b..1f14080 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,8 @@ The root of your project is expected to have a `.metadock` folder, which can be
## Basic CLI Usage
-The `metadock` CLI, installed using `pip install metadock`, has 5 basic commands, spelled out in the help message:
+The `metadock` CLI, installed using `pip install metadock`, has 5 basic commands,
+spelled out in the help message:
```sh
usage: metadock [-h] [-p PROJECT_DIR] {init,validate,build,list,clean} ...
@@ -120,7 +121,7 @@ Each of the commands supports a programmatic invocation from the `metadock.Metad
metadock.Metadock.list
(list[str], list[str]) -> metadock.engine.MetadockProjectListResult
(list[str], list[str]) -> list[str]
[IGDP-13] Adding software version as hard requirement for staging
@@ -266,9 +266,9 @@ The natively supported values for `target_formats` are:
- `md+html`:
- Generates the given template, parses it into a markdown document, and then generates HTML from it.
-- Anything else, e.g. `txt`, `sql` or `py`
-- Generates the given template as plaintext, and adds the given string as a file extension, e.g. `.txt`, `.sql` or
- `.py`.
+- Anything else, e.g. `txt`, `sql` or `py`:
+ - Generates the given template as plaintext, and adds the given string as a file extension, e.g.
+ `.txt`, `.sql` or `.py`.
## Acknowledgements
diff --git a/metadock/engine.py b/metadock/engine.py
index 707bb30..16ef5e4 100644
--- a/metadock/engine.py
+++ b/metadock/engine.py
@@ -483,12 +483,17 @@ def collect_from_file(cls, yaml_path: Path | str) -> "list[MetadockContentSchema
raise exceptions.MetadockContentSchematicParsingException(
"Missing required key for content schematic in %s: '%s'" % (yaml_path, req_key)
)
+
+ context = yaml_utils.flatten_merge_keys(def_schematic.get("context", {}))
+ context = yaml_utils.resolve_all_imports(
+ Path(str(yaml_path).split("/content_schematics/")[0]) / "content_schematics", context
+ )
content_schematics.append(
cls(
name=def_schematic["name"],
template=def_schematic["template"],
target_formats=def_schematic["target_formats"],
- context=yaml_utils.flatten_merge_keys(def_schematic.get("context", {})),
+ context=context,
)
)
diff --git a/metadock/exceptions.py b/metadock/exceptions.py
index 4f0fe78..7561597 100644
--- a/metadock/exceptions.py
+++ b/metadock/exceptions.py
@@ -12,3 +12,7 @@ class MetadockTemplateParsingException(MetadockException):
class MetadockContentSchematicParsingException(MetadockException):
pass
+
+
+class MetadockYamlImportError(MetadockException):
+ pass
diff --git a/metadock/yaml_utils.py b/metadock/yaml_utils.py
index 9c853eb..948d70c 100644
--- a/metadock/yaml_utils.py
+++ b/metadock/yaml_utils.py
@@ -1,6 +1,11 @@
import operator
from functools import reduce
-from typing import Any
+from pathlib import Path
+from typing import Any, Optional
+
+import yaml
+
+from metadock import exceptions
def flatten_merge_keys(yaml_dict: Any) -> dict:
@@ -28,3 +33,57 @@ def flatten_merge_keys(yaml_dict: Any) -> dict:
flattened_yaml_dict[key] = flat_yaml_value
return flattened_yaml_dict
+
+
+def import_key(root_path: Path, relative_path: Path, key: Optional[str] = None) -> Any:
+ """Try to import an alias from the root path with the given name.
+
+ Args:
+ root_path (Path): Absolute path to the Metadock project's content_schematics directory
+ relative_path (Path): Relative path to the external file
+ key (Optional[str]): Key path to resolve, or None to return the entire file
+
+ Raises:
+ exceptions.MetadockYamlImportError: Imported key / file could not be resolved
+
+ Returns:
+ dict: Fully resolved yaml source from the external file
+ """
+
+ if not (root_path / relative_path).exists():
+ raise exceptions.MetadockYamlImportError(f"Could not find import path '{root_path}'")
+
+ if not (root_path / relative_path).is_file():
+ raise exceptions.MetadockYamlImportError(f"Import path '{root_path}' is not a file")
+
+ contents: dict[str, Any] = yaml.load((root_path / relative_path).read_text(), yaml.BaseLoader)
+ if key is not None:
+ contents = reduce(lambda acc, el: acc[el], key.split("."), contents)
+ return resolve_all_imports(root_path, contents)
+
+
+def resolve_all_imports(root_path: Path, yaml_dict: dict[str, Any]) -> dict[str, Any]:
+ """Recursively resolve all imports in a yaml dictionary object.
+
+ Args:
+ root_path (Path): Root path to resolve the imports
+ yaml_dict (dict[str, Any]): Dictionary object with imports to resolve
+
+ Raises:
+ exceptions.MetadockYamlImportError: One or more import could not be resolved
+
+ Returns:
+ dict[str, Any]: Dictionary object with imports resolved
+ """
+ if not isinstance(yaml_dict, dict):
+ return yaml_dict # type: ignore
+
+ if set(yaml_dict.keys()) in ({"import"}, {"import", "key"}):
+ return import_key(root_path, yaml_dict["import"], yaml_dict.get("key", None))
+
+ resolved_subdict: dict[str, Any] = {}
+
+ for key in yaml_dict.keys():
+ resolved_subdict[key] = resolve_all_imports(root_path, yaml_dict[key])
+
+ return resolved_subdict
diff --git a/tests/test_engine.py b/tests/test_engine.py
index d1fdd05..10db69c 100644
--- a/tests/test_engine.py
+++ b/tests/test_engine.py
@@ -11,6 +11,17 @@ def metadock_project(empty_metadock_project_dir):
# Create some dummy files within the directories
(project_dir / "templated_documents" / "template1.md").write_text("Simple plaintext document.")
(project_dir / "templated_documents" / "template2.md").write_text("{{ var1 }} is {{ var2 }}.")
+ (project_dir / "templated_documents" / "imported.md").write_text(
+ """**Imported identity**: {{ name }} ({{ sem_version }})"""
+ )
+ (project_dir / "content_schematics" / "lib.yml").write_text(
+ """
+ identity:
+ name: lib
+ sem_version: 3.0.1
+ fix_version: 2023.04.11
+ """
+ )
(project_dir / "content_schematics" / "schematic1.yml").write_text(
"""
content_schematics:
@@ -45,6 +56,16 @@ def metadock_project(empty_metadock_project_dir):
var2: a test
"""
)
+ (project_dir / "content_schematics" / "imported.yml").write_text(
+ """
+ content_schematics:
+
+ - name: schematic_import
+ template: imported.md
+ target_formats: [ md ]
+ context: { import: lib.yml, key: identity }
+ """
+ )
return MetadockProject(project_dir)
@@ -54,7 +75,7 @@ def test_metadock_project_templated_documents_directory(metadock_project):
def test_metadock_project_templated_documents(metadock_project):
- assert len(metadock_project.templated_documents) == 2
+ assert len(metadock_project.templated_documents) == 3
def test_metadock_project_content_schematics_directory(metadock_project):
@@ -62,7 +83,7 @@ def test_metadock_project_content_schematics_directory(metadock_project):
def test_metadock_project_content_schematics(metadock_project):
- assert len(metadock_project.content_schematics) == 4
+ assert len(metadock_project.content_schematics) == 5
def test_metadock_project_generated_documents_directory(metadock_project):
@@ -73,8 +94,8 @@ def test_metadock_project_build(metadock_project):
# Test building all schematics
build_result = metadock_project.build()
- assert len(list(metadock_project.generated_documents_directory.glob("*"))) == 4
- assert len(build_result.generated_documents) == 4
+ assert len(list(metadock_project.generated_documents_directory.glob("*"))) == 5
+ assert len(build_result.generated_documents) == 5
assert all(gd.status == "new" for gd in build_result.generated_documents)
metadock_project.clean()
@@ -149,3 +170,19 @@ def test_metadock_content_schematic(metadock_project):
assert content_schem_2a.to_compiled_targets(metadock_project) == {"md": " is ."}
assert content_schem_2b.to_compiled_targets(metadock_project) == {"md": "This is a test."}
+
+
+def test_metadock_content_schematic__import_key(metadock_project):
+ content_schem_imported = metadock_project.content_schematics["schematic_import"]
+ assert content_schem_imported.context
+ assert content_schem_imported.context == {
+ "name": "lib",
+ "sem_version": "3.0.1",
+ "fix_version": "2023.04.11",
+ }
+
+ metadock_project.build(["schematic_import"])
+
+ gen_doc = metadock_project.generated_documents_directory / "schematic_import.md"
+ assert gen_doc.exists()
+ assert gen_doc.read_text() == "**Imported identity**: lib (3.0.1)"
diff --git a/tests/test_yaml_utils.py b/tests/test_yaml_utils.py
index 963302b..054d9c9 100644
--- a/tests/test_yaml_utils.py
+++ b/tests/test_yaml_utils.py
@@ -1,4 +1,8 @@
+import string
+from pathlib import Path
+
import pytest
+import yaml
from metadock import yaml_utils
@@ -50,3 +54,60 @@
)
def test_yaml_utils__flatten_merge_keys(yml_dict, flat_dict):
assert yaml_utils.flatten_merge_keys(yml_dict) == flat_dict
+
+
+@pytest.mark.parametrize(
+ "contents,key,value",
+ [
+ pytest.param(
+ "name: foo",
+ "name",
+ "foo",
+ id="simple single-key dict",
+ ),
+ pytest.param(
+ "name: foo\nvalue: bar",
+ "value",
+ "bar",
+ id="simple 2-key dict",
+ ),
+ pytest.param(
+ "name: \n x: 32\n y: 64",
+ "name",
+ {"x": "32", "y": "64"},
+ id="simple full dict query",
+ ),
+ pytest.param(
+ "name: \n x: 32\n y: 64",
+ "name.x",
+ "32",
+ id="simple dict key query",
+ ),
+ ],
+)
+def test_yaml_utils__import_key(tmp_path, contents, key, value):
+ (tmp_path / "test.yml").write_text(contents)
+ assert yaml_utils.import_key(tmp_path, Path("test.yml"), key) == value
+
+
+def test_yaml_utils__resolve_all_imports(tmp_path):
+ (tmp_path / "misc.yml").write_text("et_cetera:\n first_value: David\n second_value: Excelsior")
+
+ (tmp_path / "test1.yml").write_text("test:\n <<: { import: misc.yml, key: et_cetera.second_value }")
+ test_1_contents = yaml_utils.flatten_merge_keys(yaml.safe_load((tmp_path / "test1.yml").read_text()))
+
+ assert yaml_utils.resolve_all_imports(tmp_path, test_1_contents) == {"test": "Excelsior"}
+
+ (tmp_path / "test2.yml").write_text("test:\n <<: { import: misc.yml, key: et_cetera }")
+ test_2_contents = yaml_utils.flatten_merge_keys(yaml.safe_load((tmp_path / "test2.yml").read_text()))
+
+ assert yaml_utils.resolve_all_imports(tmp_path, test_2_contents) == {
+ "test": {"first_value": "David", "second_value": "Excelsior"}
+ }
+
+ (tmp_path / "test3.yml").write_text("test:\n <<: { import: misc.yml }")
+ test_2_contents = yaml_utils.flatten_merge_keys(yaml.safe_load((tmp_path / "test3.yml").read_text()))
+
+ assert yaml_utils.resolve_all_imports(tmp_path, test_2_contents) == {
+ "test": {"et_cetera": {"first_value": "David", "second_value": "Excelsior"}}
+ }
From 8d688bd99366826f54fd2222f2df25e91c740406 Mon Sep 17 00:00:00 2001
From: David Sillman Basic CLI Usage
metadock.Metadock.init
(Path | str) -> metadock.Metadock
(self, working_directory: Path | str = Path.cwd()) -> metadock.Metadock
Basic CLI Usage
metadock.Metadock.validate
() -> metadock.engine.MetadockProjectValidationResult
(self) -> metadock.engine.MetadockProjectValidationResult
Basic CLI Usage
metadock.Metadock.build
(list[str], list[str]) -> metadock.engine.MetadockProjectBuildResult
"(self, schematic_globs: list[str] = [], template_globs: list[str] = []) -> metadock.engine.MetadockProjectBuildResult"
Basic CLI Usage
metadock.Metadock.list
(list[str], list[str]) -> list[str]
(self, schematic_globs: list[str] = [], template_globs: list[str] = []) -> list[str]
Basic CLI Usage
metadock.Metadock.clean
() -> None
(self) -> None
Example Usage
gitlab_mr__feature1.yml
:#...
-# yaml anchor definitions
-#...
-
-content_schematics:
+
content_schematics:
- name: gitlab_mr__feature1
template: gitlab_mr_template.md
@@ -164,7 +160,8 @@
Example Usage
context:
jira:
- <<: *JiraProject-IGDP
+ project_name: "IGDP"
+ project_id: "12001"
ticket_num: "13"
merge_request:
@@ -175,8 +172,10 @@ Example Usage
breaking_changes:
- summary: "Dropping all records which are missing software version."
affected_downstream:
- - *Stakeholder-Service
- - *Stakeholder-Analytics
+ - id: Service
+ email: service@company.com
+ - id: Analytics
+ email: analytics-data@company.com
suggested_remedy: |
- Drop all records which are missing software version.
- Add software version as a hard requirement for staging.
diff --git a/.metadock/generated_documents/README.md b/.metadock/generated_documents/README.md
index 1f14080..dca259b 100644
--- a/.metadock/generated_documents/README.md
+++ b/.metadock/generated_documents/README.md
@@ -70,7 +70,7 @@ Each of the commands supports a programmatic invocation from the `metadock.Metad
metadock.Metadock.init
(Path | str) -> metadock.Metadock
(self, working_directory: Path | str = Path.cwd()) -> metadock.Metadock
metadock.Metadock.validate
() -> metadock.engine.MetadockProjectValidationResult
(self) -> metadock.engine.MetadockProjectValidationResult
metadock.Metadock.build
(list[str], list[str]) -> metadock.engine.MetadockProjectBuildResult
"(self, schematic_globs: list[str] = [], template_globs: list[str] = []) -> metadock.engine.MetadockProjectBuildResult"
metadock.Metadock.list
(list[str], list[str]) -> list[str]
(self, schematic_globs: list[str] = [], template_globs: list[str] = []) -> list[str]
metadock.Metadock.clean
() -> None
(self) -> None
metadock.Metadock.init
(Path | str) -> metadock.Metadock
(self, working_directory: Path | str = Path.cwd()) -> metadock.Metadock
metadock.Metadock.validate
() -> metadock.engine.MetadockProjectValidationResult
(self) -> metadock.engine.MetadockProjectValidationResult
metadock.Metadock.build
(list[str], list[str]) -> metadock.engine.MetadockProjectBuildResult
"(self, schematic_globs: list[str] = [], template_globs: list[str] = []) -> metadock.engine.MetadockProjectBuildResult"
metadock.Metadock.list
(list[str], list[str]) -> list[str]
(self, schematic_globs: list[str] = [], template_globs: list[str] = []) -> list[str]
metadock.Metadock.clean
() -> None
(self) -> None
).
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ html.code('This is code text.') }}").render()
+ '
This is code text.
'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockHtmlNamespace.code
+ signature: "(self, content: str) -> str"
+ intellisense:
+ snippet_key: HTML code
+ snippet_body:
+ - html.code($1)
+
+ codeblock:
+ docstring: |
+ Wraps a string in preformatted HTML code tags (
), and indents the content by the
+ given amount.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
+ '
'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockHtmlNamespace.codeblock
+ signature: "(self, content: str, indent: int = 0) -> str"
+ intellisense:
+ snippet_key: HTML codeblock
+ snippet_body:
+ - html.codeblock($1)
+
+ details:
+ docstring: |
+ Wraps a string in HTML details tags ( This is code text.
[IGDP-13] Adding software version as hard requirement for staging
+Jinja Templating Helpers
+Global namespace
+md
and html
.
+Jinja macro reference
+
+
+
+
+
+
+
+Macro
+Signature
+Doc
+
+
+
+debug
+metadock.env.MetadockEnv.debug: (self, message: str) -> None
Prints a debug message to stdout, and returns an empty string.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
+Jinja filter reference
+
+
+
+
+
+
+
+Filter
+Signature
+Doc
+
+
+
+chain
+metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
Filter which flattens a sequence of iterables into a single iterable.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
+
+
+inline
+metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
+
+
+with_prefix
+metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
Filter which prepends a prefix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
+
+
+with_suffix
+metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
Filter which appends a suffix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
+
+
+zip
+metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
Filter which zips an input iterable with one or more iterables.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
+md
namespace
+Jinja macro reference
+
+
+
+
+
+Macro
+Signature
+Doc
+
+Jinja filter reference
+
+
+
+
+
+Filter
+Signature
+Doc
+
+html
namespace
+Jinja macro reference
+
+
+
+
+
+
+
+Macro
+Signature
+Doc
+
+
+
+html.bold
+metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
Wraps a string in HTML bold tags (<b></b>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
+
+
+html.code
+metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
Wraps a string in HTML code tags (<code></code>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
+
+
+html.codeblock
+metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
+
+
+html.details
+metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
Wraps a string in HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
+
+
+html.italic
+metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
Wraps a string in HTML italic tags (<i></i>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
+Jinja filter reference
+
+
+
+
+
+Filter
+Signature
+Doc
+Acknowledgements
diff --git a/.metadock/generated_documents/README.md b/.metadock/generated_documents/README.md
index dca259b..7159b4e 100644
--- a/.metadock/generated_documents/README.md
+++ b/.metadock/generated_documents/README.md
@@ -269,6 +269,103 @@ The natively supported values for `target_formats` are:
- Generates the given template as plaintext, and adds the given string as a file extension, e.g.
`.txt`, `.sql` or `.py`.
+## Jinja Templating Helpers
+
+In the Jinja templating context which is loaded for each templated document, there are a handful of helpful Jinja macros
+and filters which can be used to make formatting content easier. The macros and filters are segregated into
+3 namespaces, documented below:
+
+### Global namespace
+
+The global namespace contains helpful macros and filters for manipulating data in the Jinja
+context. It also provides access to more specific namespaces through their respective identifiers,
+such as `md` and `html`.
+
+
+
+
+Jinja macro reference
+
+
+| Macro | Signature | Doc |
+| --- | --- | --- |
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+
+
+Jinja filter reference
+
+
+| Filter | Signature | Doc |
+| --- | --- | --- |
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+
+
+Jinja macro reference
+
+
+| Macro | Signature | Doc |
+| --- | --- | --- |
+
+
+Jinja filter reference
+
+
+| Filter | Signature | Doc |
+| --- | --- | --- |
+
+
+Jinja macro reference
+
+
+| Macro | Signature | Doc |
+| --- | --- | --- |
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+
+
+Jinja filter reference
+
+
+| Filter | Signature | Doc |
+| --- | --- | --- |
+
+
" ~ (md.codeblock(macro_spec.get("example"), language="py")
+ | md.convert | html.inline),
+ )
+}}
+{% endfor -%}
+{%- endset -%}
+{%- set ns_filter_table -%}
+{{ md.tablehead("Filter", "Signature", "Doc", bold=true) }}
+{% for filter, filter_spec in namespace_spec.get("filters", {}).items() -%}
+{{
+ md.tablerow(
+ html.code(ns_code_prefix ~ filter),
+ html.code(filter_spec.get("method_name") ~ ": " ~ filter_spec.get("signature")),
+ (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(filter_spec.get("example"), language="py")
+ | md.convert | html.inline),
+ )
+}}
+{% endfor -%}
+{%- endset -%}
+{{ namespace_intro }}
+
+{{ html.details(html.summary("Jinja macro reference"), ns_macro_table) }}
+
+{{ html.details(html.summary("Jinja filter reference"), ns_filter_table) }}
+
+{% endfor %}
+
## Acknowledgements
Author{% if (authors | length) > 1 %}s{% endif %}:
diff --git a/metadock/env.py b/metadock/env.py
index 70af74e..7d118a9 100644
--- a/metadock/env.py
+++ b/metadock/env.py
@@ -1,4 +1,5 @@
import abc
+import html
import itertools
from typing import Annotated, Any, Iterable, Literal, Sequence
@@ -129,7 +130,8 @@ def tablerow(self, *cells: str) -> str:
Returns:
str: The Markdown table row.
"""
- return "| " + " | ".join(cells) + " |"
+ _pipe_escaped_cells = tuple(map(lambda cell: cell.replace("|", "\\|"), cells))
+ return "| " + " | ".join(_pipe_escaped_cells) + " |"
def tablehead(self, *header_cells: str, bold: bool = False) -> str:
"""Produces a Markdown table header row from the given header cells.
@@ -141,9 +143,10 @@ def tablehead(self, *header_cells: str, bold: bool = False) -> str:
Returns:
str: The Markdown table header row.
"""
+ _pipe_escaped_cells = tuple(map(lambda cell: cell.replace("|", "\\|"), header_cells))
if bold:
- header_cells = tuple(MetadockHtmlNamespace().bold(cell) for cell in header_cells)
- return self.tablerow(*header_cells) + "\n" + self.tablerow(*(["---"] * len(header_cells)))
+ _pipe_escaped_cells = tuple(MetadockHtmlNamespace().bold(cell) for cell in _pipe_escaped_cells)
+ return self.tablerow(*_pipe_escaped_cells) + "\n" + self.tablerow(*(["---"] * len(_pipe_escaped_cells)))
def list(self, *items: str) -> str:
"""Produces a Markdown list from the given items, even when those items themselves may be formatted as Markdown
@@ -208,6 +211,7 @@ class MetadockHtmlNamespace(MetadockNamespace):
"""
exports = ["bold", "code", "codeblock", "details", "italic", "summary", "underline"]
+ filters = ["escape", "inline"]
def bold(self, content: str) -> str:
"""Wraps a string in HTML bold tags ().
@@ -232,8 +236,8 @@ def code(self, content: str) -> str:
return f"{content}
"
def codeblock(self, content: str, indent: int = 0) -> str:
- """Wraps a string in line-broken HTML code tags (\\n\\n
), and indents the content by the given
- amount.
+ """Wraps a string in preformatted HTML code tags (
), and indents the content by the
+ given amount.
Args:
content (str): The content to be formatted as code.
@@ -242,21 +246,21 @@ def codeblock(self, content: str, indent: int = 0) -> str:
Returns:
str: The HTML code block content.
"""
- indented_content = content.replace("\n", "\n" + " " * indent)
- return f"\n{indented_content}\n
"
+ indented_content = " " * indent + content.replace("\n", "\n" + " " * indent)
+ return f"
"
- def details(self, *contents: str, indent: int = 0) -> str:
- """Wraps a string in HTML details tags ({indented_content}
singleton tags.
+
+ Args:
+ content (str): Piped input string to be HTML-inlined.
+
+ Returns:
+ str: The HTML-inlined string.
+ """
+ return content.replace("\n", "
")
+
class MetadockEnv(MetadockNamespace):
"""Jinja namespace for the global Metadock environment, including all global exports, filters, and namespaces.
diff --git a/metadock/target_formats.py b/metadock/target_formats.py
index bcb9cbb..29d3996 100644
--- a/metadock/target_formats.py
+++ b/metadock/target_formats.py
@@ -2,6 +2,7 @@
from typing import MutableMapping, Protocol, Type
import marko
+from marko.ext.gfm import gfm
from metadock import exceptions
@@ -110,4 +111,4 @@ def handler(cls, rendered_document: str | bytes) -> str | bytes:
Returns:
str | bytes: HTML markup of the original Markdown document
"""
- return marko.convert(str(rendered_document))
+ return gfm.convert(str(rendered_document))
diff --git a/metadock/yaml_utils.py b/metadock/yaml_utils.py
index 26637b7..7bd4cdc 100644
--- a/metadock/yaml_utils.py
+++ b/metadock/yaml_utils.py
@@ -17,6 +17,9 @@ def flatten_merge_keys(yaml_dict: Any) -> dict:
Returns:
dict: Flattened representation of the nested dictionary object
"""
+ if isinstance(yaml_dict, list):
+ return [flatten_merge_keys(el) for el in yaml_dict]
+
if not isinstance(yaml_dict, dict):
return yaml_dict # type: ignore
From e39ec8830a1178210f73ff8f0bfc130d108c28e1 Mon Sep 17 00:00:00 2001
From: David Sillman html
namespace
html.details
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
Wraps a string in HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
+html.italic
metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
+
+html.summary
+metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
diff --git a/.metadock/generated_documents/README.md b/.metadock/generated_documents/README.md
index 7159b4e..339741c 100644
--- a/.metadock/generated_documents/README.md
+++ b/.metadock/generated_documents/README.md
@@ -349,8 +349,9 @@ Jinja macro reference
|
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+Jinja macro reference
+
+
+| Macro | Signature | Doc |
+| --- | --- | --- |
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+
+
+Jinja filter reference
+
+
+| Filter | Signature | Doc |
+| --- | --- | --- |
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+
+
+Jinja macro reference
+
+
+| Macro | Signature | Doc |
+| --- | --- | --- |
+
+
+Jinja filter reference
+
+
+| Filter | Signature | Doc |
+| --- | --- | --- |
+
+
+Jinja macro reference
+
+
+| Macro | Signature | Doc |
+| --- | --- | --- |
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+
+
+Jinja filter reference
+
+
+| Filter | Signature | Doc |
+| --- | --- | --- |
+
+Global namespace
debug
-metadock.env.MetadockEnv.debug: (self, message: str) -> None
Prints a debug message to stdout, and returns an empty string.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Prints a debug message to stdout, and returns an empty string.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Global namespace
chain
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
Filter which flattens a sequence of iterables into a single iterable.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'Filter which flattens a sequence of iterables into a single iterable.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
inline
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
Filter which prepends a prefix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
Filter which appends a suffix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
Filter which zips an input iterable with one or more iterables.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
@@ -354,32 +354,32 @@ md
namespacehtml
namespace
html.bold
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
Wraps a string in HTML bold tags (<b></b>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'Wraps a string in HTML bold tags (<b></b>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
html.code
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
Wraps a string in HTML code tags (<code></code>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'Wraps a string in HTML code tags (<code></code>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
html.codeblock
-metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
html.details
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
Wraps a string in HTML italic tags (<i></i>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
-| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
-| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
-| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
-| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
-| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
-| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
-| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
-| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
diff --git a/.metadock/templated_documents/repo_readme_template.md b/.metadock/templated_documents/repo_readme_template.md
index 95f21b1..d56ac29 100644
--- a/.metadock/templated_documents/repo_readme_template.md
+++ b/.metadock/templated_documents/repo_readme_template.md
@@ -109,7 +109,7 @@ and filters which can be used to make formatting content easier. The macros and
md.tablerow(
html.code(ns_code_prefix ~ macro),
html.code(macro_spec.get("method_name") ~ ": " ~ macro_spec.get("signature")),
- (macro_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(macro_spec.get("example"), language="py")
+ (macro_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(macro_spec.get("example"), language="py")
| md.convert | html.inline),
)
}}
@@ -122,7 +122,7 @@ and filters which can be used to make formatting content easier. The macros and
md.tablerow(
html.code(ns_code_prefix ~ filter),
html.code(filter_spec.get("method_name") ~ ": " ~ filter_spec.get("signature")),
- (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(filter_spec.get("example"), language="py")
+ (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(filter_spec.get("example"), language="py")
| md.convert | html.inline),
)
}}
diff --git a/README.md b/README.md
index 339741c..7744be5 100644
--- a/README.md
+++ b/README.md
@@ -290,7 +290,7 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
@@ -301,11 +301,11 @@ Jinja filter reference
| Filter | Signature | Doc |
| --- | --- | --- |
-| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
-| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
-| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
-| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
-| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
-| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
-| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
-| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
-| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
diff --git a/metadock/env.py b/metadock/env.py
index 7d118a9..64aee91 100644
--- a/metadock/env.py
+++ b/metadock/env.py
@@ -316,7 +316,7 @@ def inline_filter(self, content: str) -> str:
Returns:
str: The HTML-inlined string.
"""
- return content.replace("\n", "
")
+ return content.replace("\n", "
")
class MetadockEnv(MetadockNamespace):
From 50c986c64c0689d079a9deac68e67b3130e6c826 Mon Sep 17 00:00:00 2001
From: David Sillman Global namespace
debug
-metadock.env.MetadockEnv.debug: (self, message: str) -> None
Prints a debug message to stdout, and returns an empty string.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Prints a debug message to stdout, and returns an empty string.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Global namespace
chain
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
Filter which flattens a sequence of iterables into a single iterable.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'Filter which flattens a sequence of iterables into a single iterable.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
inline
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
Filter which prepends a prefix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
Filter which appends a suffix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
Filter which zips an input iterable with one or more iterables.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
@@ -354,32 +354,32 @@ md
namespacehtml
namespace
html.bold
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
Wraps a string in HTML bold tags (<b></b>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'Wraps a string in HTML bold tags (<b></b>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
Wraps a string in HTML code tags (<code></code>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'Wraps a string in HTML code tags (<code></code>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.codeblock
-metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'
' This is code text.
html.details
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'
html.italic
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
Wraps a string in HTML italic tags (<i></i>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.summary
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.
|
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
-| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
-| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
-| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
-| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables.
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
-| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
-| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
-| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
-| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'
' This is code text.
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
diff --git a/.metadock/templated_documents/repo_readme_template.md b/.metadock/templated_documents/repo_readme_template.md
index d56ac29..e8c28e1 100644
--- a/.metadock/templated_documents/repo_readme_template.md
+++ b/.metadock/templated_documents/repo_readme_template.md
@@ -109,8 +109,8 @@ and filters which can be used to make formatting content easier. The macros and
md.tablerow(
html.code(ns_code_prefix ~ macro),
html.code(macro_spec.get("method_name") ~ ": " ~ macro_spec.get("signature")),
- (macro_spec.get("docstring") | inline | html.escape) ~ ">>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'
" ~ (md.codeblock(macro_spec.get("example"), language="py")
- | md.convert | html.inline),
+ (macro_spec.get("docstring") | inline | html.escape) ~ "
" ~ (html.codeblock(macro_spec.get("example"))
+ | html.inline),
)
}}
{% endfor -%}
@@ -122,8 +122,8 @@ and filters which can be used to make formatting content easier. The macros and
md.tablerow(
html.code(ns_code_prefix ~ filter),
html.code(filter_spec.get("method_name") ~ ": " ~ filter_spec.get("signature")),
- (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(filter_spec.get("example"), language="py")
- | md.convert | html.inline),
+ (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (html.codeblock(filter_spec.get("example"))
+ | html.inline),
)
}}
{% endfor -%}
diff --git a/README.md b/README.md
index 7744be5..3d558ed 100644
--- a/README.md
+++ b/README.md
@@ -290,7 +290,7 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.
|
@@ -301,11 +301,11 @@ Jinja filter reference
| Filter | Signature | Doc |
| --- | --- | --- |
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
-| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
-| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
-| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
-| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables.
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
-| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
-| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
-| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
-| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'
' This is code text.
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
diff --git a/metadock/env.py b/metadock/env.py
index 64aee91..463e9a7 100644
--- a/metadock/env.py
+++ b/metadock/env.py
@@ -316,7 +316,7 @@ def inline_filter(self, content: str) -> str:
Returns:
str: The HTML-inlined string.
"""
- return content.replace("\n", ">>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'
")
+ return content.replace("\n", "
")
class MetadockEnv(MetadockNamespace):
From 8f515d20ec35ddb6d7f9f0b2d957b7092153da17 Mon Sep 17 00:00:00 2001
From: David Sillman Global namespace
debug
-metadock.env.MetadockEnv.debug: (self, message: str) -> None
Prints a debug message to stdout, and returns an empty string.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Prints a debug message to stdout, and returns an empty string.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Global namespace
chain
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
Filter which flattens a sequence of iterables into a single iterable.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'Filter which flattens a sequence of iterables into a single iterable.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
inline
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
Filter which prepends a prefix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
Filter which appends a suffix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
Filter which zips an input iterable with one or more iterables.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
@@ -354,32 +354,32 @@ md
namespacehtml
namespace
html.bold
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
Wraps a string in HTML bold tags (<b></b>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'Wraps a string in HTML bold tags (<b></b>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
html.code
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
Wraps a string in HTML code tags (<code></code>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'Wraps a string in HTML code tags (<code></code>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
html.codeblock
-metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'
' This is code text.
Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
html.details
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
Wraps a string in HTML italic tags (<i></i>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>).
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>).
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'
' This is code text.
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>).
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
diff --git a/.metadock/templated_documents/repo_readme_template.md b/.metadock/templated_documents/repo_readme_template.md
index e8c28e1..6970428 100644
--- a/.metadock/templated_documents/repo_readme_template.md
+++ b/.metadock/templated_documents/repo_readme_template.md
@@ -109,8 +109,8 @@ and filters which can be used to make formatting content easier. The macros and
md.tablerow(
html.code(ns_code_prefix ~ macro),
html.code(macro_spec.get("method_name") ~ ": " ~ macro_spec.get("signature")),
- (macro_spec.get("docstring") | inline | html.escape) ~ "
" ~ (html.codeblock(macro_spec.get("example"))
- | html.inline),
+ (macro_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(macro_spec.get("example"))
+ | md.convert | html.inline),
)
}}
{% endfor -%}
@@ -122,8 +122,8 @@ and filters which can be used to make formatting content easier. The macros and
md.tablerow(
html.code(ns_code_prefix ~ filter),
html.code(filter_spec.get("method_name") ~ ": " ~ filter_spec.get("signature")),
- (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (html.codeblock(filter_spec.get("example"))
- | html.inline),
+ (filter_spec.get("docstring") | inline | html.escape) ~ "
" ~ (md.codeblock(filter_spec.get("example"))
+ | md.convert | html.inline),
)
}}
{% endfor -%}
diff --git a/README.md b/README.md
index 3d558ed..35b3e87 100644
--- a/README.md
+++ b/README.md
@@ -290,7 +290,7 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
@@ -301,11 +301,11 @@ Jinja filter reference
| Filter | Signature | Doc |
| --- | --- | --- |
-| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables.
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>).
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>).
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'
' This is code text.
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>).
|
-| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
+| >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
From c1ef9771d9e32564a55f08310683e02a23be19bf Mon Sep 17 00:00:00 2001
From: David Sillman Global namespace
debug
-metadock.env.MetadockEnv.debug: (self, message: str) -> None
Prints a debug message to stdout, and returns an empty string.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Prints a debug message to stdout, and returns an empty string.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'Global namespace
chain
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
Filter which flattens a sequence of iterables into a single iterable.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'Filter which flattens a sequence of iterables into a single iterable.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
inline
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
Filter which prepends a prefix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
Filter which appends a suffix to a string, with an optional separator.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
Filter which zips an input iterable with one or more iterables.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
@@ -354,32 +354,32 @@ md
namespacehtml
namespace
html.bold
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
Wraps a string in HTML bold tags (<b></b>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'Wraps a string in HTML bold tags (<b></b>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
html.code
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
Wraps a string in HTML code tags (<code></code>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'Wraps a string in HTML code tags (<code></code>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
html.codeblock
-metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
html.details
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
Wraps a string in HTML italic tags (<i></i>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
+>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
-| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
-| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
-| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
-| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
-| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
-| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
-| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
-| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
diff --git a/README.md b/README.md
index 35b3e87..eb965fe 100644
--- a/README.md
+++ b/README.md
@@ -290,7 +290,7 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
+| debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
|
@@ -301,11 +301,11 @@ Jinja filter reference
| Filter | Signature | Doc |
| --- | --- | --- |
-| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
-| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
-| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
-| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
-| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
+| chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
|
+| inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
|
+| with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
|
+| with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
|
+| zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
|
@@ -346,12 +346,12 @@ Jinja macro reference
| Macro | Signature | Doc |
| --- | --- | --- |
-| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
-| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
-| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
-| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
-| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
-| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
+| html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
|
+| html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
|
+| html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
|
+| html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
|
+| html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
|
+| html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
|
diff --git a/metadock/env.py b/metadock/env.py
index 463e9a7..5267f93 100644
--- a/metadock/env.py
+++ b/metadock/env.py
@@ -316,7 +316,7 @@ def inline_filter(self, content: str) -> str:
Returns:
str: The HTML-inlined string.
"""
- return content.replace("\n", "
")
+ return content.replace("\n", "
")
class MetadockEnv(MetadockNamespace):
From 95288686e33a82a61f83732687054e3d7bce7748 Mon Sep 17 00:00:00 2001
From: David Sillman
singleton tags.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | html.inline }}").render()
+ 'This is a multi-line string.
This is the second line.
And the third.'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockHtmlNamespace.inline_filter
+ signature: "(self, content: str) -> str"
+ intellisense:
+ snippet_key: HTML inline
+ snippet_body:
+ - html.inline
diff --git a/.metadock/content_schematics/jinja_helpers/md.yml b/.metadock/content_schematics/jinja_helpers/md.yml
index 16a0c7c..b3f3f12 100644
--- a/.metadock/content_schematics/jinja_helpers/md.yml
+++ b/.metadock/content_schematics/jinja_helpers/md.yml
@@ -1,4 +1,162 @@
md:
- macros: {}
+ docstring: |
+ Jinja Namespace for Markdown-related functions and filters.
- filters: {}
+ **Macros**:
+
+ blockquote
+ code
+ codeblock
+ list
+ tablehead
+ tablerow
+
+ **Filters**:
+
+ convert
+ list
+
+ macros:
+ blockquote:
+ docstring: |
+ Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
+ '> This is a blockquote.'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.blockquote
+ signature: "(self, content: str) -> str"
+ intellisense:
+ snippet_key: Markdown blockquote
+ snippet_body:
+ - md.blockquote($1)
+
+ code:
+ docstring: |
+ Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`").
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
+ '`This is an inline code block.`'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.code
+ signature: "(self, content: str) -> str"
+ intellisense:
+ snippet_key: Markdown inline code
+ snippet_body:
+ - md.code($1)
+
+ codeblock:
+ docstring: |
+ Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"),
+ and optionally specifies a language.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
+ '```sh\nThis is a codeblock.\n```'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.codeblock
+ signature: "(self, content: str, language: str = '') -> str"
+ intellisense:
+ snippet_key: Markdown codeblock
+ snippet_body:
+ - md.codeblock($1)
+
+ list:
+ docstring: |
+ Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its
+ arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string(
+ ... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
+ ... ).render()
+ '- This is a list.\n - This is a sublist,\n - in two pieces.'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.list
+ signature: "(self, *items: str) -> str"
+ intellisense:
+ snippet_key: Markdown list
+ snippet_body:
+ - md.list($1)
+
+ tablehead:
+ docstring: |
+ Produces a Markdown table header from the given cells by joining each cell with pipes ("|") and wrapping the
+ result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash
+ ("\\"). To bold the header cell contents, supply `bold = true`.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string(
+ ... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
+ ... ).render()
+ '| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.tablehead
+ signature: "(self, *header_cells: str, bold: bool = False) -> str"
+ intellisense:
+ snippet_key: Markdown table head
+ snippet_body:
+ - md.tablehead($1)
+
+ tablerow:
+ docstring: |
+ Produces a Markdown table row from the given cells by joining each cell with pipes ("|") and wrapping the
+ result in pipes. Cell contents have their pipes escaped with a backslash ("\\").
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string(
+ ... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
+ ... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
+ ... ).render()
+ '| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |\n| Value 1 | Value 2 | Value 3 |'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.tablerow
+ signature: "(self, *row_cells: str) -> str"
+ intellisense:
+ snippet_key: Markdown table row
+ snippet_body:
+ - md.tablerow($1)
+
+ filters:
+ convert:
+ docstring: |
+ Filter which converts Markdown content to HTML, by invoking `marko.convert`.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' | md.convert }}").render()
+ 'This is a heading
\n\n
\n'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.convert_filter
+ signature: "(self, md_content: str) -> str"
+ intellisense:
+ snippet_key: Markdown convert
+ snippet_body:
+ - md.convert($1)
+
+ list:
+ docstring: |
+ Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list
+ element.
+ example: |
+ >>> from metadock.env import MetadockEnv
+ >>> env = MetadockEnv().jinja_environment()
+ >>> env.from_string(
+ ... "{{ ['This is a list.', 'This is a second element'] | md.list }}\n"
+ ... ).render()
+ '- This is a list.\n- This is a second element\n'
+ source_file: metadock/env.py
+ method_name: metadock.env.MetadockMdNamespace.list_filter
+ signature: "(self, values: str | Iterable[str]) -> str"
+ intellisense:
+ snippet_key: Markdown list
+ snippet_body:
+ - md.list
diff --git a/.metadock/generated_documents/README.html b/.metadock/generated_documents/README.html
index be69dc9..bc6ba97 100644
--- a/.metadock/generated_documents/README.html
+++ b/.metadock/generated_documents/README.html
@@ -249,9 +249,21 @@ Jinja Templating Helpers
and filters which can be used to make formatting content easier. The macros and filters are segregated into
3 namespaces, documented below:
The global namespace contains helpful macros and filters for manipulating data in the Jinja
-context. It also provides access to more specific namespaces through their respective identifiers,
-such as md
and html
.
Jinja namespace for the global Metadock environment, including all global exports, filters, and namespaces.
+Macros:
+debug
+
+Namespaces:
+html
+md
+
+Filters:
+chain
+inline
+with_prefix
+with_suffix
+zip
+
md
namespaceNone
+Jinja Namespace for Markdown-related functions and filters.
+Macros:
+blockquote
+code
+codeblock
+list
+tablehead
+tablerow
+
+Filters:
+convert
+list
+
md
namespacemd.blockquote
metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'sh\nThis is a codeblock.\n
'
md.list
metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
bold = true
. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'| <b>Column 1</b> | <b>Column 2</b> | <b>Column 3</b> |\n| --- | --- | --- |'
md.tablerow
metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |\n| Value 1 | Value 2 | Value 3 |'
md
namespacemd.convert
metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
marko.convert
. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' | md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
md.list
metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] | md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html
namespaceNone
+Jinja namespace which owns HTML-related functions and filters.
+Macros:
+bold
+code
+codeblock
+details
+italic
+summary
+underline
+
+Filters:
+escape
+inline
+
html
namespacemetadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
html.underline
metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
html
namespacehtml.escape
metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '<p>This is a paragraph.</p>' | html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
Author:
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| <b>Column 1</b> \| <b>Column 2</b> \| <b>Column 3</b> \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '<p>This is a paragraph.</p>' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| <b>Column 1</b> \| <b>Column 2</b> \| <b>Column 3</b> \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '<p>This is a paragraph.</p>' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
Jinja namespace for the global Metadock environment, including all global exports, filters, and namespaces.
+Jinja namespace for the global Metadock environment, including all global macros, filters, and namespaces.
Macros:
debug
diff --git a/.metadock/generated_documents/README.md b/.metadock/generated_documents/README.md
index 5ad7a7a..5b7486e 100644
--- a/.metadock/generated_documents/README.md
+++ b/.metadock/generated_documents/README.md
@@ -277,7 +277,7 @@ and filters which can be used to make formatting content easier. The macros and
### Global namespace
-Jinja namespace for the global Metadock environment, including all global exports, filters, and namespaces.
+Jinja namespace for the global Metadock environment, including all global macros, filters, and namespaces.
**Macros**:
diff --git a/README.md b/README.md
index 5ad7a7a..5b7486e 100644
--- a/README.md
+++ b/README.md
@@ -277,7 +277,7 @@ and filters which can be used to make formatting content easier. The macros and
### Global namespace
-Jinja namespace for the global Metadock environment, including all global exports, filters, and namespaces.
+Jinja namespace for the global Metadock environment, including all global macros, filters, and namespaces.
**Macros**:
diff --git a/metadock/env.py b/metadock/env.py
index 97892aa..69f0bfc 100644
--- a/metadock/env.py
+++ b/metadock/env.py
@@ -332,7 +332,7 @@ def inline_filter(self, content: str) -> str:
class MetadockEnv(MetadockNamespace):
- """Jinja namespace for the global Metadock environment, including all global exports, filters, and namespaces.
+ """Jinja namespace for the global Metadock environment, including all global macros, filters, and namespaces.
**Macros**:
From fad782fe445d1d1547fbc620738d5140bdd73ab8 Mon Sep 17 00:00:00 2001
From: David Sillman metadock.env.MetadockEnv.debug: (self, message: str) -> None
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
md
namespaceJinja Namespace for Markdown-related functions and filters.
Macros:
@@ -379,7 +381,8 @@md
namespacemetadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |\n| Value 1 | Value 2 | Value 3 |'
md
namespacemd.convert
metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
marko.convert
. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' | md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
marko.convert
(using github-flavored md). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' | md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
md.list
metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] | md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html
namespaceJinja namespace which owns HTML-related functions and filters.
Macros:
@@ -467,7 +471,8 @@html
namespacemetadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
html
namespacemetadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
Author:
debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
Macro | +Signature | +Doc | +
---|---|---|
debug |
+metadock.env.MetadockEnv.debug: (self, message: str) -> None |
+Prints a debug message to stdout, and returns an empty string.
|
+
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
Filter | +Signature | +Doc | +
---|---|---|
chain |
+metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any] |
+Filter which flattens a sequence of iterables into a single iterable.
|
+
inline |
+metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str |
+Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
+
with_prefix |
+metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str |
+Filter which prepends a prefix to a string, with an optional separator.
|
+
with_suffix |
+metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str |
+Filter which appends a suffix to a string, with an optional separator.
|
+
zip |
+metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]] |
+Filter which zips an input iterable with one or more iterables.
|
+
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| <b>Column 1</b> \| <b>Column 2</b> \| <b>Column 3</b> \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
Macro | +Signature | +Doc | +
---|---|---|
md.blockquote |
+metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str |
+Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
|
+
md.code |
+metadock.env.MetadockMdNamespace.code: (self, content: str) -> str |
+Produces a Markdown inline code block from the given content by wrapping the string in graves ("`").
|
+
md.codeblock |
+metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str |
+Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("```"), and optionally specifies a language.
|
+
md.list |
+metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str |
+Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
|
+
md.tablehead |
+metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str |
+Produces a Markdown table header from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\"). To bold the header cell contents, supply bold = true .
|
+
md.tablerow |
+metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str |
+Produces a Markdown table row from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\").
|
+
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
Filter | +Signature | +Doc | +
---|---|---|
md.convert |
+metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str |
+Filter which converts Markdown content to HTML, by invoking marko.convert (using github-flavored md).
|
+
md.list |
+metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str |
+Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element.
|
+
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
Macro | +Signature | +Doc | +
---|---|---|
html.bold |
+metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str |
+Wraps a string in HTML bold tags (<b></b>).
|
+
html.code |
+metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str |
+Wraps a string in HTML code tags (<code></code>).
|
+
html.codeblock |
+metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str |
+Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
+
html.details |
+metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str |
+Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
+
html.italic |
+metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str |
+Wraps a string in HTML italic tags (<i></i>).
|
+
html.summary |
+metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str |
+Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
+
html.underline |
+metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str |
+Wraps a string in HTML underline tags (<u></u>).
|
+
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '<p>This is a paragraph.</p>' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
Filter | +Signature | +Doc | +
---|---|---|
html.escape |
+metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str |
+Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents.
|
+
html.inline |
+metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str |
+Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags.
|
+
debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
Macro | +Signature | +Doc | +
---|---|---|
debug |
+metadock.env.MetadockEnv.debug: (self, message: str) -> None |
+Prints a debug message to stdout, and returns an empty string.
|
+
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
Filter | +Signature | +Doc | +
---|---|---|
chain |
+metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any] |
+Filter which flattens a sequence of iterables into a single iterable.
|
+
inline |
+metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str |
+Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
+
with_prefix |
+metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str |
+Filter which prepends a prefix to a string, with an optional separator.
|
+
with_suffix |
+metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str |
+Filter which appends a suffix to a string, with an optional separator.
|
+
zip |
+metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]] |
+Filter which zips an input iterable with one or more iterables.
|
+
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| <b>Column 1</b> \| <b>Column 2</b> \| <b>Column 3</b> \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
Macro | +Signature | +Doc | +
---|---|---|
md.blockquote |
+metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str |
+Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
|
+
md.code |
+metadock.env.MetadockMdNamespace.code: (self, content: str) -> str |
+Produces a Markdown inline code block from the given content by wrapping the string in graves ("`").
|
+
md.codeblock |
+metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str |
+Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("```"), and optionally specifies a language.
|
+
md.list |
+metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str |
+Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
|
+
md.tablehead |
+metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str |
+Produces a Markdown table header from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\"). To bold the header cell contents, supply bold = true .
|
+
md.tablerow |
+metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str |
+Produces a Markdown table row from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\").
|
+
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert`. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
Filter | +Signature | +Doc | +
---|---|---|
md.convert |
+metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str |
+Filter which converts Markdown content to HTML, by invoking marko.convert (using github-flavored md).
|
+
md.list |
+metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str |
+Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element.
|
+
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
html.codeblock
| metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
Macro | +Signature | +Doc | +
---|---|---|
html.bold |
+metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str |
+Wraps a string in HTML bold tags (<b></b>).
|
+
html.code |
+metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str |
+Wraps a string in HTML code tags (<code></code>).
|
+
html.codeblock |
+metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str |
+Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
+
html.details |
+metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str |
+Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
+
html.italic |
+metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str |
+Wraps a string in HTML italic tags (<i></i>).
|
+
html.summary |
+metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str |
+Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
+
html.underline |
+metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str |
+Wraps a string in HTML underline tags (<u></u>).
|
+
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '<p>This is a paragraph.</p>' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
Filter | +Signature | +Doc | +
---|---|---|
html.escape |
+metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str |
+Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents.
|
+
html.inline |
+metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str |
+Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags.
|
+
This is one line,
This is another.
|
\ No newline at end of file
From 3aa4ef1e7ee3365f4b9bd5a9930a57d1fec89f53 Mon Sep 17 00:00:00 2001
From: David Sillman This is one line,| \ No newline at end of file From ea1291fa06906dfd56c9ee520cb49ff4599a3da0 Mon Sep 17 00:00:00 2001 From: David Sillman
This is another.
), and indents the content by the
+ Wraps a string in preformatted HTML pre tags (), and indents the content by the
given amount.
example: |
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
- >>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
- ' This is code text.
'
+ >>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
+ 'This is code text.' source_file: metadock/env.py - method_name: metadock.env.MetadockHtmlNamespace.codeblock + method_name: metadock.env.MetadockHtmlNamespace.pre signature: "(self, content: str, indent: int = 0) -> str" intellisense: - snippet_key: HTML codeblock + snippet_key: HTML pre snippet_body: - - html.codeblock($1) + - html.pre($1) details: docstring: | diff --git a/.metadock/generated_documents/README.html b/.metadock/generated_documents/README.html index 2a87279..6e99d80 100644 --- a/.metadock/generated_documents/README.html +++ b/.metadock/generated_documents/README.html @@ -280,10 +280,9 @@
debug
metadock.env.MetadockEnv.debug: (self, message: str) -> None
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
chain
metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() | chain | join(" ") }}').render()
'first 1 second 2'
inline
metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' | with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' | with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] | zip([1, 2, 3]) | list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
md
namespaceJinja Namespace for Markdown-related functions and filters.
Macros:
@@ -354,35 +352,34 @@md
namespacemd.blockquote
metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'sh\nThis is a codeblock.\n
'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'sh\nThis is a codeblock.\n
'
md.list
metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
bold = true
. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'| <b>Column 1</b> | <b>Column 2</b> | <b>Column 3</b> |\n| --- | --- | --- |'
bold = true
. >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |'
md.tablerow
metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |\n| Value 1 | Value 2 | Value 3 |'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'| Column 1 | Column 2 | Column 3 |\n| --- | --- | --- |\n| Value 1 | Value 2 | Value 3 |'
md
namespacemd.convert
metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
marko.convert
(using github-flavored md). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' | md.convert }}").render()
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\n'
marko.convert
(using github-flavored md). >>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' | md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list
metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] | md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] | md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html
namespaceJinja namespace which owns HTML-related functions and filters.
Macros:
@@ -439,40 +435,39 @@html
namespacehtml.bold
metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'<b>This is bold text.</b>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code
metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'<code>This is code text.</code>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.codeblock
metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.codeblock('This is code text.', indent = 4) }}").render()
'<pre><code> This is code text.</code></pre>'
html.pre
metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.details
metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'<details>\nThis is details text.\n</details>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic
metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'<i>This is italic text.</i>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.summary
metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'<summary>\nThis is summary text.\n</summary>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n '
html.underline
metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'<u>This is underlined text.</u>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
html
namespacehtml.escape
metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '<p>This is a paragraph.</p>' | html.escape }}").render()
'<p>This is a paragraph.</p>'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' | html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | html.inline }}").render()
'This is a multi-line string.<br>This is the second line.<br>And the third.'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' | html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
Author:
Macro | -Signature | -Doc | -
---|---|---|
debug |
-metadock.env.MetadockEnv.debug: (self, message: str) -> None |
-Prints a debug message to stdout, and returns an empty string.
|
-
debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
Filter | -Signature | -Doc | -
---|---|---|
chain |
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any] |
-Filter which flattens a sequence of iterables into a single iterable.
|
-
inline |
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str |
-Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
-
with_prefix |
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str |
-Filter which prepends a prefix to a string, with an optional separator.
|
-
with_suffix |
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str |
-Filter which appends a suffix to a string, with an optional separator.
|
-
zip |
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]] |
-Filter which zips an input iterable with one or more iterables.
|
-
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
Macro | -Signature | -Doc | -
---|---|---|
md.blockquote |
-metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str |
-Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
|
-
md.code |
-metadock.env.MetadockMdNamespace.code: (self, content: str) -> str |
-Produces a Markdown inline code block from the given content by wrapping the string in graves ("`").
|
-
md.codeblock |
-metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str |
-Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("```"), and optionally specifies a language.
|
-
md.list |
-metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str |
-Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
|
-
md.tablehead |
-metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str |
-Produces a Markdown table header from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\"). To bold the header cell contents, supply bold = true .
|
-
md.tablerow |
-metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str |
-Produces a Markdown table row from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\").
|
-
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
Filter | -Signature | -Doc | -
---|---|---|
md.convert |
-metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str |
-Filter which converts Markdown content to HTML, by invoking marko.convert (using github-flavored md).
|
-
md.list |
-metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str |
-Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element.
|
-
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert` (using github-flavored md). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
Macro | -Signature | -Doc | -
---|---|---|
html.bold |
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str |
-Wraps a string in HTML bold tags (<b></b>).
|
-
html.code |
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str |
-Wraps a string in HTML code tags (<code></code>).
|
-
html.codeblock |
-metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str |
-Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
-
html.details |
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str |
-Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
-
html.italic |
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str |
-Wraps a string in HTML italic tags (<i></i>).
|
-
html.summary |
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str |
-Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
-
html.underline |
-metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str |
-Wraps a string in HTML underline tags (<u></u>).
|
-
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.pre
| metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n '
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
Filter | -Signature | -Doc | -
---|---|---|
html.escape |
-metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str |
-Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents.
|
-
html.inline |
-metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str |
-Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags.
|
-
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
Macro | -Signature | -Doc | -
---|---|---|
debug |
-metadock.env.MetadockEnv.debug: (self, message: str) -> None |
-Prints a debug message to stdout, and returns an empty string.
|
-
debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
Filter | -Signature | -Doc | -
---|---|---|
chain |
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any] |
-Filter which flattens a sequence of iterables into a single iterable.
|
-
inline |
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str |
-Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
|
-
with_prefix |
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str |
-Filter which prepends a prefix to a string, with an optional separator.
|
-
with_suffix |
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str |
-Filter which appends a suffix to a string, with an optional separator.
|
-
zip |
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]] |
-Filter which zips an input iterable with one or more iterables.
|
-
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
Macro | -Signature | -Doc | -
---|---|---|
md.blockquote |
-metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str |
-Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
|
-
md.code |
-metadock.env.MetadockMdNamespace.code: (self, content: str) -> str |
-Produces a Markdown inline code block from the given content by wrapping the string in graves ("`").
|
-
md.codeblock |
-metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str |
-Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("```"), and optionally specifies a language.
|
-
md.list |
-metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str |
-Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
|
-
md.tablehead |
-metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str |
-Produces a Markdown table header from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\"). To bold the header cell contents, supply bold = true .
|
-
md.tablerow |
-metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str |
-Produces a Markdown table row from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\").
|
-
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
Filter | -Signature | -Doc | -
---|---|---|
md.convert |
-metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str |
-Filter which converts Markdown content to HTML, by invoking marko.convert (using github-flavored md).
|
-
md.list |
-metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str |
-Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element.
|
-
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert` (using github-flavored md). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
Macro | -Signature | -Doc | -
---|---|---|
html.bold |
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str |
-Wraps a string in HTML bold tags (<b></b>).
|
-
html.code |
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str |
-Wraps a string in HTML code tags (<code></code>).
|
-
html.codeblock |
-metadock.env.MetadockHtmlNamespace.codeblock: (self, content: str, indent: int = 0) -> str |
-Wraps a string in preformatted HTML code tags (<pre><code></code></pre>), and indents the content by the given amount.
|
-
html.details |
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str |
-Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
|
-
html.italic |
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str |
-Wraps a string in HTML italic tags (<i></i>).
|
-
html.summary |
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str |
-Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
|
-
html.underline |
-metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str |
-Wraps a string in HTML underline tags (<u></u>).
|
-
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.pre
| metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n '
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
Filter | -Signature | -Doc | -
---|---|---|
html.escape |
-metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str |
-Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents.
|
-
html.inline |
-metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str |
-Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags.
|
-
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv| +
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
{content}
"
- def codeblock(self, content: str, indent: int = 0) -> str:
- """Wraps a string in preformatted HTML code tags (
), and indents the content by the
- given amount.
-
- Args:
- content (str): The content to be formatted as code.
- indent (int, optional): Number of spaces which should be used to indent the contents. Defaults to 0.
-
- Returns:
- str: The HTML code block content.
- """
- indented_content = " " * indent + content.replace("\n", "\n" + " " * indent)
- return f"{indented_content}
"
-
def details(self, *contents: str) -> str:
"""Wraps a string in HTML details tags ({indented_content}" + def summary(self, content: str) -> str: """Wraps a string in HTML summary tags (
This is code text.' - source_file: metadock/env.py - method_name: metadock.env.MetadockHtmlNamespace.pre - signature: "(self, content: str, indent: int = 0) -> str" - intellisense: - snippet_key: HTML pre - snippet_body: - - html.pre($1) - details: docstring: | Wraps a string in line-broken HTML details tags (
This is code text.' + source_file: metadock/env.py + method_name: metadock.env.MetadockHtmlNamespace.pre + signature: "(self, content: str, indent: int = 0) -> str" + intellisense: + snippet_key: HTML pre + snippet_body: + - html.pre($1) + summary: docstring: | Wraps a string in line-broken HTML summary tags (
Jinja namespace for the global Metadock environment, including all global macros, filters, and namespaces.
-Macros:
-debug
-
-Namespaces:
-html
-md
-
-Filters:
-chain
-inline
-with_prefix
-with_suffix
-zip
-
+The following macros are available in the global namespace:
+debug
debug |
-metadock.env.MetadockEnv.debug: (self, message: str) -> None |
+debug |
+metadock.env.MetadockEnv.debug: (self, message: str) -> None |
Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv |
The following filters are available in the global namespace:
+chain
inline
with_prefix
with_suffix
wrap
zip
chain |
-metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any] |
+chain |
+metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any] |
Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv |
inline |
-metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str |
+inline |
+metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str |
Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv |
with_prefix |
-metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str |
+with_prefix |
+metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str |
Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv |
with_suffix |
-metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str |
+with_suffix |
+metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str |
Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv |
zip |
-metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]] |
+wrap |
+metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str |
+Filter which wraps an inner string with a given outer string. >>> from metadock.env import MetadockEnv |
+
zip |
+metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]] |
Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv |
md
namespaceconvert
list
+The following macros are available in the md namespace:
+md.blockquote
md.code
md.codeblock
md.list
md.tablehead
md.tablerow
md.blockquote |
-metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str |
+md.blockquote |
+metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str |
Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv |
md.code |
-metadock.env.MetadockMdNamespace.code: (self, content: str) -> str |
+md.code |
+metadock.env.MetadockMdNamespace.code: (self, content: str) -> str |
Produces a Markdown inline code block from the given content by wrapping the string in graves ("`"). >>> from metadock.env import MetadockEnv |
md.codeblock |
-metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str |
+md.codeblock |
+metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str |
Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("```"), and optionally specifies a language. >>> from metadock.env import MetadockEnv |
md.list |
-metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str |
+md.list |
+metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str |
Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv |
md.tablehead |
-metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str |
+md.tablehead |
+metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str |
Produces a Markdown table header from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\"). To bold the header cell contents, supply bold = true . >>> from metadock.env import MetadockEnv |
md.tablerow |
-metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str |
+md.tablerow |
+metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str |
Produces a Markdown table row from the given cells by joining each cell with pipes ("|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\"). >>> from metadock.env import MetadockEnv |
The following filters are available in the md namespace:
+md.convert
md.list
md.convert |
-metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str |
+md.convert |
+metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str |
Filter which converts Markdown content to HTML, by invoking marko.convert (using github-flavored md). >>> from metadock.env import MetadockEnv |
md.list |
-metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str |
+md.list |
+metadock.env.MetadockMdNamespace.list_filter: (self, values: str | Iterable[str]) -> str |
Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv |
html
namespaceJinja namespace which owns HTML-related functions and filters.
-Macros:
-bold
-code
-codeblock
-details
-italic
-summary
-underline
-
-Filters:
-escape
-inline
-
+The following macros are available in the html namespace:
+html.bold
html.code
html.details
html.italic
html.pre
html.summary
html.underline
html.bold |
-metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str |
+html.bold |
+metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str |
Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv |
html.code |
-metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str |
+html.code |
+metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str |
Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv |
html.pre |
-metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str |
-Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv |
-||
html.details |
-metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str |
+html.details |
+metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str |
Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv |
html.italic |
-metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str |
+html.italic |
+metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str |
Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv |
html.summary |
-metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str |
+html.pre |
+metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str |
+Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv |
+
html.summary |
+metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str |
Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv |
||
html.underline |
-metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str |
+html.underline |
+metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str |
Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv |
The following filters are available in the html namespace:
+html.escape
html.inline
html.escape |
-metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str |
+html.escape |
+metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str |
Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv |
html.inline |
-metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str |
+html.inline |
+metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str |
Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv |
debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
debug|
metadock.env.MetadockEnv.debug: (self, message: str) -> None| Prints a debug message to stdout, and returns an empty string.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
chain|
metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]| Filter which flattens a sequence of iterables into a single iterable.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline|
metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix|
metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str| Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix|
metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str| Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
wrap|
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str| Filter which wraps an inner string with a given outer string.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' \| wrap('`') }}").render()
'`This is a string.`'
zip|
metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]| Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
md.blockquote|
metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code|
metadock.env.MetadockMdNamespace.code: (self, content: str) -> str| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`").
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock|
metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list|
metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead|
metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|'
md.tablerow|
metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\").
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert` (using github-flavored md). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
md.convert|
metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str| Filter which converts Markdown content to HTML, by invoking `marko.convert` (using github-flavored md).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list|
metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.pre
| metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n
'
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
html.bold|
metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str| Wraps a string in HTML bold tags (<b></b>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code|
metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str| Wraps a string in HTML code tags (<code></code>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.details|
metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic|
metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str| Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.pre|
metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str| Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.summary|
metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n
'
html.underline|
metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str| Wraps a string in HTML underline tags (<u></u>).
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
html.escape|
metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline|
metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
debug
| metadock.env.MetadockEnv.debug: (self, message: str) -> None
| Prints a debug message to stdout, and returns an empty string.>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
debug|
metadock.env.MetadockEnv.debug: (self, message: str) -> None| Prints a debug message to stdout, and returns an empty string.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("No changes!{{ debug('This is a debug message.') }}").render()
This is a debug message.
'No changes!'
chain
| metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]
| Filter which flattens a sequence of iterables into a single iterable. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline
| metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str
| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix
| metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str
| Filter which prepends a prefix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix
| metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str
| Filter which appends a suffix to a string, with an optional separator. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
zip
| metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]
| Filter which zips an input iterable with one or more iterables. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
chain|
metadock.env.MetadockEnv.chain_filter: (self, iterables: Sequence[Iterable[Any]]) -> Iterable[Any]| Filter which flattens a sequence of iterables into a single iterable.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string('{{ {"first": 1, "second": 2}.items() \| chain \| join(" ") }}').render()
'first 1 second 2'
inline|
metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix|
metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str| Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix|
metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str| Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
wrap|
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str| Filter which wraps an inner string with a given outer string.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' \| wrap('`') }}").render()
'`This is a string.`'
zip|
metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]| Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
md.blockquote
| metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str
| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> "). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code
| metadock.env.MetadockMdNamespace.code: (self, content: str) -> str
| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`"). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock
| metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str
| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list
| metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str
| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead
| metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str
| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|'
md.tablerow
| metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str
| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\"). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
md.blockquote|
metadock.env.MetadockMdNamespace.blockquote: (self, content: str) -> str| Produces a Markdown blockquote from the given content by prepending each line with a gt symbol ("> ").
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.blockquote('This is a blockquote.') }}").render()
'> This is a blockquote.'
md.code|
metadock.env.MetadockMdNamespace.code: (self, content: str) -> str| Produces a Markdown inline code block from the given content by wrapping the string in graves ("\`").
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.code('This is an inline code block.') }}").render()
'`This is an inline code block.`'
md.codeblock|
metadock.env.MetadockMdNamespace.codeblock: (self, content: str, language: str = '') -> str| Produces a Markdown codeblock from the given content by wrapping the string in triple-graves ("\`\`\`"), and optionally specifies a language.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ md.codeblock('This is a codeblock.', language = 'sh') }}").render()
'```sh\nThis is a codeblock.\n```'
md.list|
metadock.env.MetadockMdNamespace.list: (self, *items: str) -> str| Produces a Markdown list from the given content by prepending each line with a dash ("- "). If any of its arguments are, themselves, formatted as Markdown lists, then they are simply indented as sublists.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.list('This is a list.', md.list('This is a sublist,', 'in two pieces.')) }}"
... ).render()
'- This is a list.\n - This is a sublist,\n - in two pieces.'
md.tablehead|
metadock.env.MetadockMdNamespace.tablehead: (self, *header_cells: str, bold: bool = False) -> str| Produces a Markdown table header from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes, plus adding a header divider row. Cell contents have their pipes escaped with a backslash ("\\"). To bold the header cell contents, supply `bold = true`.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3', bold = true) }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|'
md.tablerow|
metadock.env.MetadockMdNamespace.tablerow: (self, *row_cells: str) -> str| Produces a Markdown table row from the given cells by joining each cell with pipes ("\|") and wrapping the result in pipes. Cell contents have their pipes escaped with a backslash ("\\").
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ md.tablehead('Column 1', 'Column 2', 'Column 3') }}\n"
... "{{ md.tablerow('Value 1', 'Value 2', 'Value 3') }}"
... ).render()
'\| Column 1 \| Column 2 \| Column 3 \|\n\| --- \| --- \| --- \|\n\| Value 1 \| Value 2 \| Value 3 \|'
md.convert
| metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str
| Filter which converts Markdown content to HTML, by invoking `marko.convert` (using github-flavored md). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list
| metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str
| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
md.convert|
metadock.env.MetadockMdNamespace.convert_filter: (self, md_content: str) -> str| Filter which converts Markdown content to HTML, by invoking `marko.convert` (using github-flavored md).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ '# This is a heading\n\n> And a block quote.' \| md.convert }}").render()
'This is a heading
\n\n\n'And a block quote.
\n
md.list|
metadock.env.MetadockMdNamespace.list_filter: (self, values: str \| Iterable[str]) -> str| Filter which unpacks an iterable of values into a Markdown list, or formats a single value as a Markdown list element.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string(
... "{{ ['This is a list.', 'This is a second element'] \| md.list }}\n"
... ).render()
'- This is a list.\n- This is a second element\n'
html.bold
| metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str
| Wraps a string in HTML bold tags (<b></b>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code
| metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str
| Wraps a string in HTML code tags (<code></code>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.pre
| metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str
| Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.details
| metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str
| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic
| metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str
| Wraps a string in HTML italic tags (<i></i>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.summary
| metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str
| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>). >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n
'
html.underline
| metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str
| Wraps a string in HTML underline tags (<u></u>). >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
html.bold|
metadock.env.MetadockHtmlNamespace.bold: (self, content: str) -> str| Wraps a string in HTML bold tags (<b></b>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.bold('This is bold text.') }}").render()
'This is bold text.'
html.code|
metadock.env.MetadockHtmlNamespace.code: (self, content: str) -> str| Wraps a string in HTML code tags (<code></code>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.code('This is code text.') }}").render()
'This is code text.
'
html.details|
metadock.env.MetadockHtmlNamespace.details: (self, *contents: str) -> str| Wraps a string in line-broken HTML details tags (<details></details>). Multiple arguments get separated by two line breaks.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.details('This is details text.') }}").render()
'\nThis is details text.\n'
html.italic|
metadock.env.MetadockHtmlNamespace.italic: (self, content: str) -> str| Wraps a string in HTML italic tags (<i></i>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.italic('This is italic text.') }}").render()
'This is italic text.'
html.pre|
metadock.env.MetadockHtmlNamespace.pre: (self, content: str, indent: int = 0) -> str| Wraps a string in preformatted HTML pre tags (<pre></pre>), and indents the content by the given amount.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.pre('This is code text.', indent = 4) }}").render()
'This is code text.'
html.summary|
metadock.env.MetadockHtmlNamespace.summary: (self, content: str) -> str| Wraps a string in line-broken HTML summary tags (<summary>\n\n</summary>).
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.summary('This is summary text.') }}").render()
'\nThis is summary text.\n
'
html.underline|
metadock.env.MetadockHtmlNamespace.underline: (self, content: str) -> str| Wraps a string in HTML underline tags (<u></u>).
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ html.underline('This is underlined text.') }}").render()
'This is underlined text.'
html.escape
| metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str
| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents. >>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline
| metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str
| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags. >>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
html.escape|
metadock.env.MetadockHtmlNamespace.escape_filter: (self, content: str) -> str| Filter which escapes a string by replacing all HTML special characters with their HTML entity equivalents.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a paragraph.
' \| html.escape }}").render()
'<p>This is a paragraph.</p>'
html.inline|
metadock.env.MetadockHtmlNamespace.inline_filter: (self, content: str) -> str| Filter which inlines a string by replacing all newlines with HTML line-breaks <br> singleton tags.
>>> from metadock.env import MetadockEnv|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| html.inline }}").render()
'This is a multi-line string.
This is the second line.
And the third.'
wrap
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' | wrap('') }}").render()<br>'
This is a string.`'
>>> from metadock.env import MetadockEnv
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' | wrap('`') }}").render()
'`This is a string.`'
zip
inline|
metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv| |
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix|
metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str| Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| |
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix|
metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str| Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
wrap|
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str| Filter which wraps an inner string with a given outer string.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' \| wrap('`') }}").render()
'`This is a string.`'
wrap|
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str| Filter which wraps an inner string with a given outer string.
>>> from metadock.env import MetadockEnv| |
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' \| wrap('\`') }}").render()
'\`This is a string.\`'
zip|
metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]| Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv| diff --git a/README.md b/README.md index 201b193..bd99715 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,7 @@ The following filters are available in the global namespace: |
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
inline|
metadock.env.MetadockEnv.inline_filter: (self, value: str) -> str| Filter which inlines a string by replacing all newlines with spaces, and all double spaces with single spaces.
>>> from metadock.env import MetadockEnv| |
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a multi-line string.\nThis is the second line.\nAnd the third.' \| inline }}").render()
'This is a multi-line string. This is the second line. And the third.'
with_prefix|
metadock.env.MetadockEnv.with_prefix_filter: (self, value: str, prefix: str, sep: str = '') -> str| Filter which prepends a prefix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| |
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix') }}").render()
'PrefixThis is a string.'
>>> env.from_string("{{ 'This is a string.' \| with_prefix('Prefix: ', sep = ' : ') }}").render()
'Prefix : This is a string.'
with_suffix|
metadock.env.MetadockEnv.with_suffix_filter: (self, value: str, suffix: str, sep: str = '') -> str| Filter which appends a suffix to a string, with an optional separator.
>>> from metadock.env import MetadockEnv| -|
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix') }}").render()
'This is a stringSuffix'
>>> env.from_string("{{ 'This is a string' \| with_suffix('Suffix', sep = ' : ') }}").render()
'This is a string : Suffix'
wrap|
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str| Filter which wraps an inner string with a given outer string.
>>> from metadock.env import MetadockEnv| +|
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' \| wrap('`') }}").render()
'`This is a string.`'
wrap|
metadock.env.MetadockEnv.wrap_filter: (self, value: str, wrap: str) -> str| Filter which wraps an inner string with a given outer string.
>>> from metadock.env import MetadockEnv| |
>>> env = MetadockEnv().jinja_environment()
>>> # Wrap with graves, like md.code(...)
>>> env.from_string("{{ 'This is a string.' \| wrap('\`') }}").render()
'\`This is a string.\`'
zip|
metadock.env.MetadockEnv.zip_filter: (self, input_iterable: Iterable[Any], *iterables: Iterable[Any]) -> Iterable[tuple[Any, ...]]| Filter which zips an input iterable with one or more iterables.
>>> from metadock.env import MetadockEnv| From 71c339cbf118a437d742f30ead8651d7a7b32147 Mon Sep 17 00:00:00 2001 From: David Sillman
>>> env = MetadockEnv().jinja_environment()
>>> env.from_string("{{ ['a', 'b', 'c'] \| zip([1, 2, 3]) \| list }}").render()
"[('a', 1), ('b', 2), ('c', 3)]"
For more information, please check out the Jira ticket associated with this MR, IGDP-13.
\ No newline at end of file +For more information, please check out the Jira ticket associated with this MR, IGDP-13.
diff --git a/.metadock/generated_documents/README.html b/.metadock/generated_documents/README.html index 8526bbc..1260001 100644 --- a/.metadock/generated_documents/README.html +++ b/.metadock/generated_documents/README.html @@ -244,6 +244,64 @@In order to keep your content schematics DRY, you can use YAML imports to split your content schematics into multiple
+YAML files. For example, if you have a set of content schematics responsible for laying out a "knowledge base" of
+services maintained by your team, you might have a YAML file for each service, e.g.
+services/airflow/google_forms_scrubber.yml
and services/pipelines/user_interaction_data_pipeline.yml
which
+separately model their respective service specifications.
A content schematic can import context from a specific YAML key in another YAML file by using the special import-key +object, e.g.:
+content_schematics:
+
+- name: alerting_project_proposal
+ template: airflow_project_proposal_template.md
+ target_formats: [ md+html, md ]
+
+ context:
+
+ jira:
+
+ # "block" syntax for importing a root-level key "IGDP"
+ project:
+ import: jira/projects.yml
+ key: IGDP
+
+ # "flow" syntax for importing a sub-key, "David_Sillman" inside "eng_identity"
+ code_owners:
+ - { import: jira/identities.yml, key: eng_identity.David_Sillman }
+
+ # "flow" syntax for importing a sub-key using a merge key ("<<"),
+ <<: { import: team_contexts/data.yml, key: resources.alerting_channels }
+
+ # "block" syntax for importing multiple subkeys from multiple files using a merge key,
+ <<:
+ - import: team_contexts/data_contacts.yml
+ key: contacts.email
+ - import: team_contexts/data_push_api.yml
+ key: push_api.contracts
+
+Note that all paths for the import
field are relative to the content_schematics
folder for the project.
+If you'd like to import the entire content of a file as context, you may omit the key
field, e.g.:
content_schematics:
+
+- name: confluence_docs_summary
+ template: confluence/data_docs/confluence_docs_summary_template.md
+ target_formats: [ md+html, md ]
+ context:
+
+ # "block" syntax for whole-file import,
+ all_contracts:
+ import: confluence/data_docs/contracts.yml
+
+ # "flow" syntax for importing multiple whole files using a merge key,
+ <<:
+ - import: confluence/data_docs/projects.yml
+ - import: confluence/data_docs/sources.yml
+
+At the moment, no protection against cyclic dependencies are implemented (apart from a recursion depth exception which +will likely be thrown before memory is consumed). Users are responsible for ensuring that their imports do not create +cyclic dependencies.
In the Jinja templating context which is loaded for each templated document, there are a handful of helpful Jinja macros
and filters which can be used to make formatting content easier. The macros and filters are segregated into
diff --git a/.metadock/generated_documents/README.md b/.metadock/generated_documents/README.md
index bd99715..1aecb28 100644
--- a/.metadock/generated_documents/README.md
+++ b/.metadock/generated_documents/README.md
@@ -269,6 +269,73 @@ The natively supported values for `target_formats` are:
- Generates the given template as plaintext, and adds the given string as a file extension, e.g.
`.txt`, `.sql` or `.py`.
+## Code splitting with YAML imports
+
+In order to keep your content schematics DRY, you can use YAML imports to split your content schematics into multiple
+YAML files. For example, if you have a set of content schematics responsible for laying out a "knowledge base" of
+services maintained by your team, you might have a YAML file for each service, e.g.
+`services/airflow/google_forms_scrubber.yml` and `services/pipelines/user_interaction_data_pipeline.yml` which
+separately model their respective service specifications.
+
+A content schematic can import context from a specific YAML key in another YAML file by using the special _import-key_
+object, e.g.:
+
+```yml
+content_schematics:
+
+- name: alerting_project_proposal
+ template: airflow_project_proposal_template.md
+ target_formats: [ md+html, md ]
+
+ context:
+
+ jira:
+
+ # "block" syntax for importing a root-level key "IGDP"
+ project:
+ import: jira/projects.yml
+ key: IGDP
+
+ # "flow" syntax for importing a sub-key, "David_Sillman" inside "eng_identity"
+ code_owners:
+ - { import: jira/identities.yml, key: eng_identity.David_Sillman }
+
+ # "flow" syntax for importing a sub-key using a merge key ("<<"),
+ <<: { import: team_contexts/data.yml, key: resources.alerting_channels }
+
+ # "block" syntax for importing multiple subkeys from multiple files using a merge key,
+ <<:
+ - import: team_contexts/data_contacts.yml
+ key: contacts.email
+ - import: team_contexts/data_push_api.yml
+ key: push_api.contracts
+```
+
+Note that all paths for the `import` field are relative to the `content_schematics` folder for the project.
+If you'd like to import the entire content of a file as context, you may omit the `key` field, e.g.:
+
+```yml
+content_schematics:
+
+- name: confluence_docs_summary
+ template: confluence/data_docs/confluence_docs_summary_template.md
+ target_formats: [ md+html, md ]
+ context:
+
+ # "block" syntax for whole-file import,
+ all_contracts:
+ import: confluence/data_docs/contracts.yml
+
+ # "flow" syntax for importing multiple whole files using a merge key,
+ <<:
+ - import: confluence/data_docs/projects.yml
+ - import: confluence/data_docs/sources.yml
+```
+
+At the moment, no protection against cyclic dependencies are implemented (apart from a recursion depth exception which
+will likely be thrown before memory is consumed). Users are responsible for ensuring that their imports do not create
+cyclic dependencies.
+
## Jinja Templating Helpers
In the Jinja templating context which is loaded for each templated document, there are a handful of helpful Jinja macros
diff --git a/.metadock/templated_documents/repo_readme_template.md b/.metadock/templated_documents/repo_readme_template.md
index c3cbf35..2948fd4 100644
--- a/.metadock/templated_documents/repo_readme_template.md
+++ b/.metadock/templated_documents/repo_readme_template.md
@@ -88,6 +88,38 @@ The natively supported values for `target_formats` are:
- Generates the given template as plaintext, and adds the given string as a file extension, e.g.
`.txt`, `.sql` or `.py`.
+## Code splitting with YAML imports
+
+In order to keep your content schematics DRY, you can use YAML imports to split your content schematics into multiple
+YAML files. For example, if you have a set of content schematics responsible for laying out a "knowledge base" of
+services maintained by your team, you might have a YAML file for each service, e.g.
+`services/airflow/google_forms_scrubber.yml` and `services/pipelines/user_interaction_data_pipeline.yml` which
+separately model their respective service specifications.
+
+A content schematic can import context from a specific YAML key in another YAML file by using the special _import-key_
+object, e.g.:
+
+{{
+ md.codeblock(
+ example_project.get("content_schematics").get("import_key_examples.yml"),
+ language="yml",
+ )
+}}
+
+Note that all paths for the `import` field are relative to the `content_schematics` folder for the project.
+If you'd like to import the entire content of a file as context, you may omit the `key` field, e.g.:
+
+{{
+ md.codeblock(
+ example_project.get("content_schematics").get("import_key_examples_2.yml"),
+ language="yml",
+ )
+}}
+
+At the moment, no protection against cyclic dependencies are implemented (apart from a recursion depth exception which
+will likely be thrown before memory is consumed). Users are responsible for ensuring that their imports do not create
+cyclic dependencies.
+
## Jinja Templating Helpers
In the Jinja templating context which is loaded for each templated document, there are a handful of helpful Jinja macros
diff --git a/README.md b/README.md
index bd99715..1aecb28 100644
--- a/README.md
+++ b/README.md
@@ -269,6 +269,73 @@ The natively supported values for `target_formats` are:
- Generates the given template as plaintext, and adds the given string as a file extension, e.g.
`.txt`, `.sql` or `.py`.
+## Code splitting with YAML imports
+
+In order to keep your content schematics DRY, you can use YAML imports to split your content schematics into multiple
+YAML files. For example, if you have a set of content schematics responsible for laying out a "knowledge base" of
+services maintained by your team, you might have a YAML file for each service, e.g.
+`services/airflow/google_forms_scrubber.yml` and `services/pipelines/user_interaction_data_pipeline.yml` which
+separately model their respective service specifications.
+
+A content schematic can import context from a specific YAML key in another YAML file by using the special _import-key_
+object, e.g.:
+
+```yml
+content_schematics:
+
+- name: alerting_project_proposal
+ template: airflow_project_proposal_template.md
+ target_formats: [ md+html, md ]
+
+ context:
+
+ jira:
+
+ # "block" syntax for importing a root-level key "IGDP"
+ project:
+ import: jira/projects.yml
+ key: IGDP
+
+ # "flow" syntax for importing a sub-key, "David_Sillman" inside "eng_identity"
+ code_owners:
+ - { import: jira/identities.yml, key: eng_identity.David_Sillman }
+
+ # "flow" syntax for importing a sub-key using a merge key ("<<"),
+ <<: { import: team_contexts/data.yml, key: resources.alerting_channels }
+
+ # "block" syntax for importing multiple subkeys from multiple files using a merge key,
+ <<:
+ - import: team_contexts/data_contacts.yml
+ key: contacts.email
+ - import: team_contexts/data_push_api.yml
+ key: push_api.contracts
+```
+
+Note that all paths for the `import` field are relative to the `content_schematics` folder for the project.
+If you'd like to import the entire content of a file as context, you may omit the `key` field, e.g.:
+
+```yml
+content_schematics:
+
+- name: confluence_docs_summary
+ template: confluence/data_docs/confluence_docs_summary_template.md
+ target_formats: [ md+html, md ]
+ context:
+
+ # "block" syntax for whole-file import,
+ all_contracts:
+ import: confluence/data_docs/contracts.yml
+
+ # "flow" syntax for importing multiple whole files using a merge key,
+ <<:
+ - import: confluence/data_docs/projects.yml
+ - import: confluence/data_docs/sources.yml
+```
+
+At the moment, no protection against cyclic dependencies are implemented (apart from a recursion depth exception which
+will likely be thrown before memory is consumed). Users are responsible for ensuring that their imports do not create
+cyclic dependencies.
+
## Jinja Templating Helpers
In the Jinja templating context which is loaded for each templated document, there are a handful of helpful Jinja macros
From b60b5504ad3c84c1f5390011aabf8036a164bc79 Mon Sep 17 00:00:00 2001
From: David Sillman Code splitting with YAML imports
target_formats: [ md+html, md ]
context:
- # "block" syntax for whole-file import,
- all_contracts:
- import: confluence/data_docs/contracts.yml
+ # "flow" syntax for a single whole-file import,
+ all_contracts: { import: confluence/data_docs/contracts.yml }
- # "flow" syntax for importing multiple whole files using a merge key,
+ # "block" syntax for importing multiple whole files using a merge key,
<<:
- import: confluence/data_docs/projects.yml
- import: confluence/data_docs/sources.yml
diff --git a/.metadock/generated_documents/README.md b/.metadock/generated_documents/README.md
index 1aecb28..569cfe0 100644
--- a/.metadock/generated_documents/README.md
+++ b/.metadock/generated_documents/README.md
@@ -322,11 +322,10 @@ content_schematics:
target_formats: [ md+html, md ]
context:
- # "block" syntax for whole-file import,
- all_contracts:
- import: confluence/data_docs/contracts.yml
+ # "flow" syntax for a single whole-file import,
+ all_contracts: { import: confluence/data_docs/contracts.yml }
- # "flow" syntax for importing multiple whole files using a merge key,
+ # "block" syntax for importing multiple whole files using a merge key,
<<:
- import: confluence/data_docs/projects.yml
- import: confluence/data_docs/sources.yml
diff --git a/README.md b/README.md
index 1aecb28..569cfe0 100644
--- a/README.md
+++ b/README.md
@@ -322,11 +322,10 @@ content_schematics:
target_formats: [ md+html, md ]
context:
- # "block" syntax for whole-file import,
- all_contracts:
- import: confluence/data_docs/contracts.yml
+ # "flow" syntax for a single whole-file import,
+ all_contracts: { import: confluence/data_docs/contracts.yml }
- # "flow" syntax for importing multiple whole files using a merge key,
+ # "block" syntax for importing multiple whole files using a merge key,
<<:
- import: confluence/data_docs/projects.yml
- import: confluence/data_docs/sources.yml