-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c1ef977
commit 9528868
Showing
12 changed files
with
734 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
'| <b>Column 1</b> | <b>Column 2</b> | <b>Column 3</b> |\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() | ||
'<h1>This is a heading</h1>\n<blockquote>\n<p>And a block quote.</p>\n</blockquote>\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 |
Oops, something went wrong.