{#- Siehe https://gitlab.gwdg.de/GAUMI-fginfo/fg-website/-/blob/better-content-renderer/docs/content.md -#}
{%- macro render_content(content, lang, header_level_offset, in_footer) -%}
{%- set meta = namespace(header_level_offset=header_level_offset, in_footer=in_footer) -%}
{{ render_blocks(content, lang, meta) }}
{%- endmacro -%}
{%- macro render_link(link, content, lang, attr = None, title = None) -%}
{%- call(objtype, obj) common.render_link_raw(link, content, lang, attr, title) -%}
{%- if content is string or content is none -%}
{%- if content is string and content|length -%}
{{ common.encoded_span(content) }}
{%- else -%}
{{ common.encoded_span(obj.title) }}
{%- endif -%}
{%- else -%}
{{ render_inlines(content, lang) }}
{%- endif -%}
{%- endcall -%}
{%- endmacro -%}
{%- macro render_header(content, level, attr, lang, in_footer) -%}
{%- call common.render_header_raw(content, level, attr, lang, in_footer=in_footer) -%}
{{ render_inlines(content, lang) }}
{%- endcall -%}
{%- endmacro -%}
{%- macro render_orderedlist_type(style, delim) -%}
{#- TODO also use delim: default | period | one_parenthesis | two_parentheses -#}
{%- if style == "default" -%}1
{%- elif style == "lower_alpha" -%}a
{%- elif style == "upper_alpha" -%}A
{%- elif style == "lower_roman" -%}i
{%- elif style == "upper_roman" -%}I
{%- elif style == "example" -%}1
{%- else -%}1
{%- endif -%}
{%- endmacro -%}
{%- macro render_image(link, alt, lang, attr = None, title = None) -%}
{%- call(resolvedlink, objtype, obj) common.resolve_link(link) -%}
{%- set ns = namespace(url=resolvedlink.urlwithanchor) -%}
{%- if not resolvedlink.is_external -%}
{%- if resolvedlink.url|length -%}
{%- set ns.url = [siteurl, ns.url]|join("/") -%}
{%- endif -%}
{%- endif -%}
{%- endcall -%}
{%- endmacro -%}
{#- ############################ BLOCKS ################################### -#}
{%- macro render_blocks(blocks, lang, meta) -%}
{%- for block in blocks -%}
{{ render_block(block, lang, meta) }}
{%- endfor -%}
{%- endmacro -%}
{%- macro render_block(block, lang, meta) -%}
{%- set etype = block['etype'] -%}
{%- if etype == "header" -%}
{{ render_block_header(block, lang, meta) }}
{%- elif etype == "paragraph" -%}
{{ render_block_paragraph(block, lang, meta) }}
{%- elif etype == "bulletlist" -%}
{{ render_block_bulletlist(block, lang, meta) }}
{%- elif etype == "plain" -%}
{{ render_block_plain(block, lang, meta) }}
{%- elif etype == "codeblock" -%}
{{ render_block_codeblock(block, lang, meta) }}
{%- elif etype == "blockquote" -%}
{{ render_block_blockquote(block, lang, meta) }}
{%- elif etype == "blockcontainer" -%}
{{ render_block_blockcontainer(block, lang, meta) }}
{%- elif etype == "horizontalrule" -%}
{{ render_block_horizontalrule(block, lang, meta) }}
{%- elif etype == "rawblock" -%}
{{ render_block_rawblock(block, lang, meta) }}
{%- elif etype == "orderedlist" -%}
{{ render_block_orderedlist(block, lang, meta) }}
{%- elif etype == "table" -%}
{{ render_block_table(block, lang, meta) }}
{%- elif etype == "definitionlist" -%}
{{ render_block_definitionlist(block, lang, meta) }}
{%- elif etype == "lineblock" -%}
{{ render_block_lineblock(block, lang, meta) }}
{%- else -%}
ERROR: Unhandled block type: '{{ etype|e }}'
{%- endif -%}
{%- endmacro -%}
{%- macro render_block_header(block, lang, meta) -%}
{%- set level = block['level'] -%}
{%- set attr = block['attr'] -%}
{%- set content = block['content'] -%}
{{ render_header(content, level + meta.header_level_offset, attr, lang, meta.in_footer) }}
{%- endmacro -%}
{%- macro render_block_paragraph(block, lang, meta) -%}
{%- set content = block['content'] -%}
{{ render_inlines(content, lang) }}
{%- endmacro -%} {%- macro render_block_bulletlist(block, lang, meta) -%} {%- set items = block['items'] -%} {%- set count = block['count'] -%}{{ code|e }}{%- endmacro -%} {%- macro render_block_blockquote(block, lang, meta) -%} {%- set content = block['content'] -%}
{{ render_blocks(content, lang, meta) }}{%- endmacro -%} {%- macro render_block_blockcontainer(block, lang, meta) -%} {%- set attr = block['attr'] -%} {%- set content = block['content'] -%}
{{ code|e }}
{%- endmacro -%}
{%- macro render_inline_quoted(inline, lang) -%}
{%- set quotetype = inline['quotetype'] -%}
{%- set content = inline['content'] -%}
{%- if quotetype == "single" -%}
{{ t[lang].quotations.single.left }}{{ render_inlines(content, lang) }}{{ t[lang].quotations.single.right }}
{%- elif quotetype == "double" -%}
{{ t[lang].quotations.double.left }}{{ render_inlines(content, lang) }}{{ t[lang].quotations.double.right }}
{%- else -%}
"{{ render_inlines(content, lang) }}"
{%- endif -%}
{%- endmacro -%}
{%- macro render_inline_footnote(inline, lang) -%}
{%- set content = inline['content'] -%}
[TODO FOOTNOTES]
{%- endmacro -%}
{%- macro render_inline_link(inline, lang) -%}
{%- set attr = inline['attr'] -%}
{%- set content = inline['content'] -%}
{%- set link = inline['link'] -%}
{%- set title = inline['title'] -%}
{{ render_link(link, content, lang, attr, title) }}
{%- endmacro -%}
{%- macro render_inline_image(inline, lang) -%}
{%- set attr = inline['attr'] -%}
{%- set alt = inline['alt'] -%}
{%- set link = inline['link'] -%}
{%- set title = inline['title'] -%}
{{ render_image(link, alt, lang, attr, title) }}
{%- endmacro -%}
{%- macro render_inline_math(inline, lang) -%}
{%- set mathtype = inline['mathtype'] -%}
{%- set math = inline['math'] -%}
{%- if mathtype == "inline" -%}
\({{ math|e }}\)
{%- elif mathtype == "display" -%}
\[{{ math|e }}\]
{%- else -%}