From afa2cb2fa6ef87919314f8d0986dd8e228435bc4 Mon Sep 17 00:00:00 2001 From: Jake <j.vondoemming@stud.uni-goettingen.de> Date: Sat, 7 May 2022 16:54:42 +0200 Subject: [PATCH] added theme --- theme/config.json | 0 theme/meta.json | 5 + theme/parsers.json | 84 ++++ theme/settings.json | 2 + theme/templates/Makefile | 3 + theme/templates/default.html.j2 | 1 + theme/templates/native.j2 | 437 ++++++++++++++++++ theme/templates/pandoc.j2 | 263 +++++++++++ theme/templates/site.html.j2 | 60 +++ .../templates/template.html | 0 10 files changed, 855 insertions(+) create mode 100644 theme/config.json create mode 100644 theme/meta.json create mode 100644 theme/parsers.json create mode 100644 theme/settings.json create mode 100644 theme/templates/Makefile create mode 100644 theme/templates/default.html.j2 create mode 100644 theme/templates/native.j2 create mode 100644 theme/templates/pandoc.j2 create mode 100644 theme/templates/site.html.j2 rename template.html => theme/templates/template.html (100%) diff --git a/theme/config.json b/theme/config.json new file mode 100644 index 0000000..e69de29 diff --git a/theme/meta.json b/theme/meta.json new file mode 100644 index 0000000..a0c8e98 --- /dev/null +++ b/theme/meta.json @@ -0,0 +1,5 @@ +{ + "version": "0.1.0", + "name": "Default Theme", + "supported_languages": [ "en" ] +} diff --git a/theme/parsers.json b/theme/parsers.json new file mode 100644 index 0000000..7a221d6 --- /dev/null +++ b/theme/parsers.json @@ -0,0 +1,84 @@ +{ + "mimetypes": { + "text/markdown": { + "type": "pandoc", + "base": "markdown", + "extensions": { + "abbreviations": { "enabled": true }, + "all_symbols_escapable": { "enabled": true }, + "amuse": { "enabled": false, "ignore": true }, + "angle_brackets_escapable": { "enabled": false }, + "ascii_identifiers": { "enabled": true }, + "auto_identifiers": { "enabled": true }, + "autolink_bare_uris": { "enabled": true }, + "backtick_code_blocks": { "enabled": true }, + "blank_before_blockquote": { "enabled": false }, + "blank_before_header": { "enabled": false }, + "bracketed_spans": { "enabled": true }, + "citations": { "enabled": false }, + "compact_definition_lists": { "enabled": false }, + "definition_lists": { "enabled": true }, + "east_asian_line_breaks": { "enabled": false }, + "emoji": { "enabled": true }, + "empty_paragraphs": { "enabled": false, "ignore": true }, + "epub_html_exts": { "enabled": false, "ignore": true }, + "escaped_line_breaks": { "enabled": true }, + "example_lists": { "enabled": true }, + "fancy_lists": { "enabled": true }, + "fenced_code_attributes": { "enabled": true }, + "fenced_code_blocks": { "enabled": true }, + "fenced_divs": { "enabled": true }, + "footnotes": { "enabled": true }, + "four_space_rule": { "enabled": false }, + "gfm_auto_identifiers": { "enabled": true }, + "grid_tables": { "enabled": true }, + "hard_line_breaks": { "enabled": true }, + "header_attributes": { "enabled": true }, + "ignore_line_breaks": { "enabled": false }, + "implicit_figures": { "enabled": true }, + "implicit_header_references": { "enabled": true }, + "inline_code_attributes": { "enabled": true }, + "inline_notes": { "enabled": true }, + "intraword_underscores": { "enabled": true }, + "latex_macros": { "enabled": true }, + "line_blocks": { "enabled": true }, + "link_attributes": { "enabled": true }, + "lists_without_preceding_blankline": { "enabled": true }, + "literate_haskell": { "enabled": false }, + "markdown_attribute": { "enabled": false }, + "markdown_in_html_blocks": { "enabled": false }, + "mmd_header_identifiers": { "enabled": false }, + "mmd_link_attributes": { "enabled": false }, + "mmd_title_block": { "enabled": false }, + "multiline_tables": { "enabled": true }, + "native_divs": { "enabled": true }, + "native_spans": { "enabled": true }, + "ntb": { "enabled": true, "ignore": true }, + "old_dashes": { "enabled": false }, + "pandoc_title_block": { "enabled": false }, + "pipe_tables": { "enabled": true }, + "raw_attribute": { "enabled": true }, + "raw_html": { "enabled": true }, + "raw_tex": { "enabled": true }, + "shortcut_reference_links": { "enabled": true }, + "simple_tables": { "enabled": true }, + "smart": { "enabled": true }, + "space_in_atx_header": { "enabled": true }, + "spaced_reference_links": { "enabled": false }, + "startnum": { "enabled": true }, + "strikeout": { "enabled": true }, + "subscript": { "enabled": true }, + "superscript": { "enabled": true }, + "styles": { "enabled": false, "ignore": true }, + "table_captions": { "enabled": true }, + "tex_math_dollars": { "enabled": true }, + "tex_math_double_backslash": { "enabled": false }, + "tex_math_single_backslash": { "enabled": true }, + "yaml_metadata_block": { "enabled": true } + } + }, + "application/json": { + "type": "json" + } + } +} diff --git a/theme/settings.json b/theme/settings.json new file mode 100644 index 0000000..2c63c08 --- /dev/null +++ b/theme/settings.json @@ -0,0 +1,2 @@ +{ +} diff --git a/theme/templates/Makefile b/theme/templates/Makefile new file mode 100644 index 0000000..a009275 --- /dev/null +++ b/theme/templates/Makefile @@ -0,0 +1,3 @@ +.PHONY: run +run: + make -C ~/stuff/fissg/fissg diff --git a/theme/templates/default.html.j2 b/theme/templates/default.html.j2 new file mode 100644 index 0000000..f3e333e --- /dev/null +++ b/theme/templates/default.html.j2 @@ -0,0 +1 @@ +<h1>Hello World</h1> diff --git a/theme/templates/native.j2 b/theme/templates/native.j2 new file mode 100644 index 0000000..ab519c2 --- /dev/null +++ b/theme/templates/native.j2 @@ -0,0 +1,437 @@ +{%- macro abort(error) -%} + {# None['[ERROR] ' ~ error][0] #} + <br>ERROR: '{{error|e}}'<br> +{%- endmacro -%} + +{%- macro render(nat) -%} + {{ render_blocks(nat,nat.blocks) }} +{%- endmacro -%} + +{%- macro render_blocks(nat, blocks) -%} + {%- for block in blocks -%} + {{ render_block(nat,block) }} + {%- endfor -%} +{%- endmacro -%} + +{%- macro render_block(nat, block) -%} + {#- TODO definitionlist , footnotes , tables -#} + {%- if block.type == "space" -%} + {{ render_space(nat, block) }} + {%- elif block.type == "string" -%} + {{ render_string(nat, block) }} + {%- elif block.type == "paragraph" -%} + {{ render_paragraph(nat, block) }} + {%- elif block.type == "plain" -%} + {{ render_plain(nat, block) }} + {%- elif block.type == "span" -%} + {{ render_span(nat, block) }} + {%- elif block.type == "div" -%} + {{ render_div(nat, block) }} + {%- elif block.type == "strong" -%} + {{ render_strong(nat, block) }} + {%- elif block.type == "emph" -%} + {{ render_emph(nat, block) }} + {%- elif block.type == "strikeout" -%} + {{ render_strikeout(nat, block) }} + {%- elif block.type == "subscript" -%} + {{ render_subscript(nat, block) }} + {%- elif block.type == "superscript" -%} + {{ render_superscript(nat, block) }} + {%- elif block.type == "linebreak" -%} + {{ render_linebreak(nat, block) }} + {%- elif block.type == "horizontalrule" -%} + {{ render_horizontalrule(nat, block) }} + {%- elif block.type == "link" -%} + {{ render_link(nat, block) }} + {%- elif block.type == "rawinline" -%} + {{ render_rawinline(nat, block) }} + {%- elif block.type == "rawblock" -%} + {{ render_rawblock(nat, block) }} + {%- elif block.type == "image" -%} + {{ render_image(nat, block) }} + {%- elif block.type == "table" -%} + {{ render_table(nat, block) }} + {%- elif block.type == "blockquote" -%} + {{ render_blockquote(nat, block) }} + {%- elif block.type == "quoted" -%} + {{ render_quoted(nat, block) }} + {%- elif block.type == "code" -%} + {{ render_code(nat, block) }} + {%- elif block.type == "codeblock" -%} + {{ render_codeblock(nat, block) }} + {%- elif block.type == "bulletlist" -%} + {{ render_bulletlist(nat, block) }} + {%- elif block.type == "orderedlist" -%} + {{ render_orderedlist(nat, block) }} + {%- elif block.type == "math" -%} + {{ render_math(nat, block) }} + {%- elif block.type == "header" -%} + {{ render_header(nat, block) }} + {%- else -%} + {{ abort(block) }} + {%- endif -%} +{%- endmacro -%} + + +{%- macro render_attr_with_extra_classes(attr, classes) -%} +{%- if attr.id %}id="{{ attr.id|e }}"{% endif %} {% if attr.classes or classes %}class="{{ (classes) | join(" ")}}{% if classes and attr.classes %} {% endif %}{{ (attr.classes) | join(" ") }}"{% endif %} {% if attr[2] %}{% for attrkey in attr.other %}{{ attrkey|e }}="{{ attr.other[attrkey]|e }}" {% endfor %}{% endif -%} +{%- endmacro -%} + +{%- macro render_space(nat, block) %} {% endmacro -%} + +{%- macro render_attr(attr) -%} +{{ render_attr_with_extra_classes(attr, []) }} +{%- endmacro -%} + +{%- macro render_string(nat, block) -%} +{{ block.content|e }} +{%- endmacro -%} + +{%- macro render_rawinline(nat, block) -%} +{{ block.raw }} +{%- endmacro -%} + +{%- macro render_rawblock(nat, block) -%} +{{ block.raw }} +{%- endmacro -%} + +{%- macro render_header(nat, block) -%} +<header> +<h{{block.level}} {{ render_attr(block.attr) }}>{{ render_blocks(nat,block.content) }}</h{{block.level}}> +</header> +{%- endmacro -%} + +{%- macro render_paragraph(nat, block) -%} +<p> +{{ render_blocks(nat, block.content)}} +</p> +{%- endmacro -%} + +{%- macro render_blockquote(nat, block) -%} +<blockquote> +{{ render_blocks(nat, block.content)}} +</blockquote> +{%- endmacro -%} + +{%- macro render_plain(nat, block) -%} +{{ render_blocks(nat, block.content)}} +{%- endmacro -%} + +{%- macro render_span(nat, block) -%} +<span {{ render_attr(block.attr) }}>{{ render_blocks(nat, block.content)}}</span> +{%- endmacro -%} + +{%- macro render_div(nat, block) -%} +<div {{ render_attr(block.attr) }}> +{{ render_blocks(nat, block.content)}} +</div> +{%- endmacro -%} + + +{%- macro render_strong(nat, block) -%} +<strong>{{ render_blocks(nat, block.content)}}</strong> +{%- endmacro -%} + +{%- macro render_emph(nat, block) -%} +<i>{{ render_blocks(nat, block.content)}}</i> +{%- endmacro -%} + +{%- macro render_strikeout(nat, block) -%} +<del>{{ render_blocks(nat,block.content) }}</del> +{%- endmacro -%} + +{%- macro render_subscript(nat, block) -%} +<sub>{{ render_blocks(nat,block.content) }}</sub> +{%- endmacro -%} + +{%- macro render_superscript(nat, block) -%} +<sup>{{ render_blocks(nat,block.content) }}</sup> +{%- endmacro -%} + +{%- macro render_table(nat, block) -%} +TODO: render_table +{%- endmacro -%} + +{%- macro render_linebreak(nat, block) -%} +<br> +{%- endmacro -%} + + +{%- macro render_link(nat, block) -%} +{#- + {'type': 'link', + 'attr': {'id': '', 'classes': [], 'other': {}}, + 'content': [], + 'href': '/', + 'is_url_external': False, + 'url_starts_with_slash': True, + 'url_starts_with_dot': False, + 'title': None} +-#} +<a {{ render_attr(block.attr) }} href="{{ block.href|e }}" {% if block.title %}title="{{ block.title|e}}"{% endif %}>{{ render_blocks(nat,block.content) }}</a> +{%- endmacro -%} + + +{%- macro render_image(nat, block) -%} +{#- +{ + 'type': 'image', + 'attr': {'id': '', 'classes': [], 'other': {}}, + 'alt': [{'type': 'string', 'content': 'imgur'}], + 'src': 'https://i.imgur.com/9cgQVqD.png', + 'is_url_external': True, + 'url_starts_with_slash': False, + 'url_starts_with_dot': False, + 'is_figure': True}' +-#} +<img {{ render_attr(block.attr) }} src="{{ block.src|e }}" {% if block.title %}title="{{ block.title|e}}"{% endif %} alt="{{ render_blocks(meta,block.alt) }}"> +{%- endmacro -%} + + +{%- macro render_code(nat, block) -%} +<code {{ render_attr_with_extra_classes(block.attr,["inline-code"]) }} >{{ block.raw|e }}</code> +{%- endmacro -%} + +{%- macro render_codeblock(nat, block) -%} +<pre {{ render_attr_with_extra_classes(block.attr,["codeblock"]) }}><code> +{%- for line in block["lines"] -%} +{%- if not loop.first -%} +{{ render_linebreak(nat, None) }} +{%- endif -%} +{{ line|e }} +{%- endfor -%} +</code></pre> +{%- endmacro -%} + +{%- macro render_bulletlistitem(nat, block) -%} +<li>{{ render_blocks(nat, block.content)}}</li> +{%- endmacro -%} + +{%- macro render_bulletlist(nat, block) -%} +<ul> +{%- for litem in block["items"] -%} +{{ render_bulletlistitem(nat, litem)}} +{%- endfor -%} +</ul> +{%- endmacro -%} + + +{%- macro render_orderedlist(nat, block) -%} +<ol start="{{ block.start_num }}" type=" +{%- if block.style_raw == "Decimal" -%}1 +{%- elif block.style_raw == "UpperRoman" -%}I +{%- elif block.style_raw == "LowerRoman" -%}i +{%- elif block.style_raw == "UpperAlpha" -%}A +{%- elif block.style_raw == "LowerAlpha" -%}a +{%- endif -%} +" class=" +{%- if block.context_raw == "Period" -%}ol-delim-period +{%- elif block.context_raw == "OneParen" -%}ol-delim-oneparen +{%- elif block.context_raw == "TwoParens" -%}ol-delim-twoparens +{%- endif -%} +"> +{%- for litem in block["items"] -%} +<li>{{ render_blocks(nat, litem)}}</li> +{%- endfor -%} +</ol> +{%- endmacro -%} + + +{%- macro render_math(nat, block) -%} +{%- if block.math_type == "display" -%} +<div class="math display-math"> +{{ block.math|e }} +</div> +{%- elif block.math_type == "inline" -%} +<span class="math inline-math">{{ block.math|e }}</span> +{%- endif -%} +{%- endmacro -%} + + +{%- macro render_horizontalrule(nat, block) -%} +<hr> +{%- endmacro -%} + +{%- macro render_quoted(nat, block) -%} +{%- if block.quote_type == "double" -%} +“{{ render_blocks(nat,block.content) }}†+{%- elif block.quote_type == "single" -%} +‘{{ render_blocks(nat,block.content) }}’ +{%- endif -%} +{%- endmacro -%} + + + +{# +------------------------------------------------------------------------------- + +{%- macro render_para(meta, block) -%} +<p> +{{ render_blocks(meta,block.c) }} +</p> +{%- endmacro -%} + +{%- macro render_emph(meta, block) -%} +<i>{{ render_blocks(meta,block.c) }}</i> +{%- endmacro -%} + + +{%- macro render_linebreak(meta, block) -%} +<br> +{%- endmacro -%} + +{%- macro render_horizontalrule(meta, block) -%} +<hr> +{%- endmacro -%} + +{%- macro render_rawinline(meta, block) -%} +{%- if block.c[0] != "html" -%} +{{ abort("Refusing to render non html rawinline: " ~ block.c[0]) }} +{%- endif -%} +{{ block.c[1] }} +{%- endmacro -%} + +{%- macro render_link(meta, block) -%} +<a {{ render_tag_attr(block.c[0]) }} href="{{ block.c[2][0] }}" {% if block.c[2][1] %}title="{{ block.c[2][1]}}"{% endif %}>{{ render_blocks(meta,block.c[1]) }}</a> +{%- endmacro -%} + +{%- macro render_image(meta, block) -%} +{%- if not block.c[1] -%} + {{ abort("Refusing to render image without alt tag: " ~ block.c[2][0] )}} +{%- endif -%} +{%- if block.c[2][1] == "fig:" -%} +<figure> + <img {{ render_tag_attr(block.c[0]) }} src="{{ block.c[2][0] }}" alt="{{ render_blocks(meta,block.c[1]) }}" title="{{ render_blocks(meta,block.c[1]) }}"> + <figcaption>{{ render_blocks(meta,block.c[1]) }}</figcaption> +</figure> +{%- else -%} +<img {{ render_tag_attr(block.c[0]) }} src="{{ block.c[2][0] }}" alt="{{ render_blocks(meta,block.c[1]) }}" {% if block.c[2][1] %}title="{{ block.c[2][1]}}"{% endif %}> +{%- endif -%} +{%- endmacro -%} + +{%- macro render_span(meta, block) -%} +<span {{ render_tag_attr(block.c[0]) }} >{{ render_blocks(meta,block.c[1]) }}</span> +{%- endmacro -%} + +{%- macro render_div(meta, block) -%} +<div {{ render_tag_attr(block.c[0]) }} > +{{ render_blocks(meta,block.c[1]) }} +</div> +{%- endmacro -%} + +{%- macro render_code(meta, block) -%} +<code {{ render_tag_attr_with_extra_classes(block.c[0],["inline-code"]) }} >{{ block.c[1] }}</code> +{%- endmacro -%} + +{%- macro render_codeblock(meta, block) -%} +<pre {{ render_tag_attr_with_extra_classes(block.c[0],["codeblock"]) }}><code>{{ block.c[1] }}</code></pre> +{%- endmacro -%} + +{%- macro render_table(meta, block) -%} +RENDER_TODO(TABLE) +{{ block | tojson() }} +{%- endmacro -%} + +{%- macro render_listitems(meta, listitems) -%} +{%- for listitem in listitems -%} + {%- for sublistitem in listitem -%} +<li> + {%- if sublistitem.t == "Plain" -%} + {{ render_blocks(meta, sublistitem.c) }} + {%- elif sublistitem.t == "BulletList" -%} + {{ render_bulletlist(meta, sublistitem) }} + {%- elif sublistitem.t == "OrderedList" -%} + {{ render_orderedlist(meta, sublistitem) }} + {%- elif sublistitem.t == "Para" -%} + {{ render_para(meta, sublistitem) }} + {%- else -%} + {{ abort("Cannot render listitem: " ~ sublistitem|tojson() ) }} + {%- endif -%} +</li> + {%- endfor -%} +{%- endfor -%} +{%- endmacro -%} + +{%- macro render_bulletlist(meta, block) -%} +<ul> +{{ render_listitems(meta, block.c) }} +</ul> +{%- endmacro -%} + +{%- macro render_orderedlist(meta, block) -%} +<ol {% if block.c[0][0] != 1 -%}start="{{ block.c[0][0] }}"{%- endif %} type=" +{%- if block.c[0][1].t == "Decimal" -%}1 +{%- elif block.c[0][1].t == "UpperRoman" -%}I +{%- elif block.c[0][1].t == "LowerRoman" -%}i +{%- elif block.c[0][1].t == "UpperAlpha" -%}A +{%- elif block.c[0][1].t == "LowerAlpha" -%}a +{%- else -%}{{ abort("Cannot render ordered list with listtype: " ~ block.c[0][1].t) }}{%- endif -%} +" class=" +{%- if block.c[0][2].t == "Period" -%}ol-delim-period +{%- elif block.c[0][2].t == "OneParen" -%}ol-delim-oneparen +{%- elif block.c[0][2].t == "TwoParens" -%}ol-delim-twoparens +{%- else -%}{{ abort("Cannot render ordered list with delimtype: " ~ block.c[0][2].t) }}{%- endif -%} +"> +{{ render_listitems(meta, block.c[1]) }} +</ol> +{%- endmacro -%} + +{%- macro render_blockquote(meta, block) -%} +<blockquote> +{{ render_blocks(meta,block.c) }} +</blockquote> +{%- endmacro -%} + +{%- macro render_quoted(meta, block) -%} +{%- if block.c[0].t == "DoubleQuote" -%} +“{{ render_blocks(meta,block.c[1]) }}†+{%- elif block.c[0].t == "SingleQuote" -%} +‘{{ render_blocks(meta,block.c[1]) }}’ +{%- else -%} +{{ abort("Cannot render quoted with type: " ~ block.c[0].t) }} +{%- endif -%} +{%- endmacro -%} + +{%- macro render_strikeout(meta, block) -%} +<del>{{ render_blocks(meta,block.c) }}</del> +{%- endmacro -%} + +{%- macro render_subscript(meta, block) -%} +<sub>{{ render_blocks(meta,block.c) }}</sub> +{%- endmacro -%} + +{%- macro render_superscript(meta, block) -%} +<sup>{{ render_blocks(meta,block.c) }}</sup> +{%- endmacro -%} + +{%- macro render_footnote_link(meta, block) -%} +{%- set footnote_counter = footnote_counter + 1 -%} +<sup class="footnote-ref"><a title="Footnote {{ footnote_counter }}" id="fnref{{ footnote_counter }}" href="#fn{{ footnote_counter }}">[{{ footnote_counter }}]</a></sup> +{%- endmacro -%} + +{%- macro render_math(meta, block) -%} +{%- if block.c|length != 2 -%} +{{ abort("Refusing to render math with block.c|length == " ~ block.c|length ~ ":" ~ block|tojson() ) }} +{%- endif -%} +{%- if block.c[0].t == "DisplayMath" -%} +<div class="math display-math"> +{{ block.c[1] }} +</div> +{%- elif block.c[0].t == "InlineMath" -%} +<span class="math inline-math">{{ block.c[1] }}</span> +{%- else -%} +{{ abort("Cannot render math: " ~ block.c[0].t) }} +{%- endif -%} +{%- endmacro -%} + + + + + + + + +{%- if not footnote_counter is defined -%} +{%- set footnote_counter = 0 -%} +{%- endif -%} +#} diff --git a/theme/templates/pandoc.j2 b/theme/templates/pandoc.j2 new file mode 100644 index 0000000..7170d3c --- /dev/null +++ b/theme/templates/pandoc.j2 @@ -0,0 +1,263 @@ +{%- macro abort(error) -%} + { None['[ERROR] ' ~ error][0] } +{%- endmacro -%} + +{%- macro render(meta, blocks) -%} + {{ render_blocks(meta,blocks) }} +{%- endmacro -%} + +{%- macro render_blocks(meta, blocks) -%} + {%- for block in blocks -%} + {{ render_block(meta,block) }} + {%- endfor -%} +{%- endmacro -%} + +{%- macro render_block(meta, block) -%} + {%- if block.t == "Str" -%} + {{ render_string(meta, block) }} + {%- elif block.t == "Space" -%} + {{ render_space(meta, block) }} + {%- elif block.t == "LineBreak" -%} + {{ render_linebreak(meta, block) }} + {%- elif block.t == "Para" -%} + {{ render_para(meta, block) }} + {%- elif block.t == "Link" -%} + {{ render_link(meta, block) }} + {%- elif block.t == "Emph" -%} + {{ render_emph(meta, block) }} + {%- elif block.t == "Strong" -%} + {{ render_strong(meta, block) }} + {%- elif block.t == "Span" -%} + {{ render_span(meta, block) }} + {%- elif block.t == "Div" -%} + {{ render_div(meta, block) }} + {%- elif block.t == "Image" -%} + {{ render_image(meta, block) }} + {%- elif block.t == "RawInline" -%} + {{ render_rawinline(meta, block) }} + {%- elif block.t == "Header" -%} + {{ render_header(meta, block) }} + {%- elif block.t == "OrderedList" -%} + {{ render_orderedlist(meta, block) }} + {%- elif block.t == "BulletList" -%} + {{ render_bulletlist(meta, block) }} + {%- elif block.t == "Code" -%} + {{ render_code(meta, block) }} + {%- elif block.t == "CodeBlock" -%} + {{ render_codeblock(meta, block) }} + {%- elif block.t == "BlockQuote" -%} + {{ render_blockquote(meta, block) }} + {%- elif block.t == "Quoted" -%} + {{ render_quoted(meta, block) }} + {%- elif block.t == "Strikeout" -%} + {{ render_strikeout(meta, block) }} + {%- elif block.t == "Superscript" -%} + {{ render_superscript(meta, block) }} + {%- elif block.t == "Subscript" -%} + {{ render_subscript(meta, block) }} + {%- elif block.t == "Note" -%} + {{ render_footnote_link(meta, block) }} + {%- elif block.t == "Math" -%} + {{ render_math(meta, block) }} + {%- elif block.t == "HorizontalRule" -%} + {{ render_horizontalrule(meta, block) }} + {%- elif block.t == "Table" -%} + {{ render_table(meta, block) }} + {%- else -%} + {{ abort("Cannot render: " ~ block.t ) }} + {%- endif -%} +{%- endmacro -%} + + +{%- macro render_tag_attr_with_extra_classes(attr, classes) -%} +{%- if attr[0] %}id="{{ attr[0] }}"{% endif %} {% if attr[1] or classes %}class="{{ classes | join(" ")}}{% if classes and attr[1] %} {% endif %}{{ attr[1] | join(" ") }}"{% endif %} {% if attr[2] %}{% for attritem in attr[2] %}{{ attritem[0] }}="{{ attritem[1] }}" {% endfor %}{% endif -%} +{%- endmacro -%} + +{%- macro render_tag_attr(attr) -%} +{{ render_tag_attr_with_extra_classes(attr, []) }} +{%- endmacro -%} + +{%- macro render_header(meta, block) -%} +<header> +<h{{block.c[0]}} {{ render_tag_attr(block.c[1]) }}>{{ render_blocks(meta,block.c[2]) }}</h{{block.c[0]}}> +</header> +{%- endmacro -%} + +{%- macro render_string(meta, block) -%} +{{ block.c }} +{%- endmacro -%} + +{%- macro render_para(meta, block) -%} +<p> +{{ render_blocks(meta,block.c) }} +</p> +{%- endmacro -%} + +{%- macro render_strong(meta, block) -%} +<strong>{{ render_blocks(meta,block.c) }}</strong> +{%- endmacro -%} +{%- macro render_emph(meta, block) -%} +<i>{{ render_blocks(meta,block.c) }}</i> +{%- endmacro -%} + +{%- macro render_space(meta, block) %} {% endmacro -%} + +{%- macro render_linebreak(meta, block) -%} +<br> +{%- endmacro -%} + +{%- macro render_horizontalrule(meta, block) -%} +<hr> +{%- endmacro -%} + +{%- macro render_rawinline(meta, block) -%} +{%- if block.c[0] != "html" -%} +{{ abort("Refusing to render non html rawinline: " ~ block.c[0]) }} +{%- endif -%} +{{ block.c[1] }} +{%- endmacro -%} + +{%- macro render_link(meta, block) -%} +<a {{ render_tag_attr(block.c[0]) }} href="{{ block.c[2][0] }}" {% if block.c[2][1] %}title="{{ block.c[2][1]}}"{% endif %}>{{ render_blocks(meta,block.c[1]) }}</a> +{%- endmacro -%} + +{%- macro render_image(meta, block) -%} +{%- if not block.c[1] -%} + {{ abort("Refusing to render image without alt tag: " ~ block.c[2][0] )}} +{%- endif -%} +{%- if block.c[2][1] == "fig:" -%} +<figure> + <img {{ render_tag_attr(block.c[0]) }} src="{{ block.c[2][0] }}" alt="{{ render_blocks(meta,block.c[1]) }}" title="{{ render_blocks(meta,block.c[1]) }}"> + <figcaption>{{ render_blocks(meta,block.c[1]) }}</figcaption> +</figure> +{%- else -%} +<img {{ render_tag_attr(block.c[0]) }} src="{{ block.c[2][0] }}" alt="{{ render_blocks(meta,block.c[1]) }}" {% if block.c[2][1] %}title="{{ block.c[2][1]}}"{% endif %}> +{%- endif -%} +{%- endmacro -%} + +{%- macro render_span(meta, block) -%} +<span {{ render_tag_attr(block.c[0]) }} >{{ render_blocks(meta,block.c[1]) }}</span> +{%- endmacro -%} + +{%- macro render_div(meta, block) -%} +<div {{ render_tag_attr(block.c[0]) }} > +{{ render_blocks(meta,block.c[1]) }} +</div> +{%- endmacro -%} + +{%- macro render_code(meta, block) -%} +<code {{ render_tag_attr_with_extra_classes(block.c[0],["inline-code"]) }} >{{ block.c[1] }}</code> +{%- endmacro -%} + +{%- macro render_codeblock(meta, block) -%} +<pre {{ render_tag_attr_with_extra_classes(block.c[0],["codeblock"]) }}><code>{{ block.c[1] }}</code></pre> +{%- endmacro -%} + +{%- macro render_table(meta, block) -%} +RENDER_TODO(TABLE) +{{ block | tojson() }} +{%- endmacro -%} + +{%- macro render_listitems(meta, listitems) -%} +{%- for listitem in listitems -%} + {%- for sublistitem in listitem -%} +<li> + {%- if sublistitem.t == "Plain" -%} + {{ render_blocks(meta, sublistitem.c) }} + {%- elif sublistitem.t == "BulletList" -%} + {{ render_bulletlist(meta, sublistitem) }} + {%- elif sublistitem.t == "OrderedList" -%} + {{ render_orderedlist(meta, sublistitem) }} + {%- elif sublistitem.t == "Para" -%} + {{ render_para(meta, sublistitem) }} + {%- else -%} + {{ abort("Cannot render listitem: " ~ sublistitem|tojson() ) }} + {%- endif -%} +</li> + {%- endfor -%} +{%- endfor -%} +{%- endmacro -%} + +{%- macro render_bulletlist(meta, block) -%} +<ul> +{{ render_listitems(meta, block.c) }} +</ul> +{%- endmacro -%} + +{%- macro render_orderedlist(meta, block) -%} +<ol {% if block.c[0][0] != 1 -%}start="{{ block.c[0][0] }}"{%- endif %} type=" +{%- if block.c[0][1].t == "Decimal" -%}1 +{%- elif block.c[0][1].t == "UpperRoman" -%}I +{%- elif block.c[0][1].t == "LowerRoman" -%}i +{%- elif block.c[0][1].t == "UpperAlpha" -%}A +{%- elif block.c[0][1].t == "LowerAlpha" -%}a +{%- else -%}{{ abort("Cannot render ordered list with listtype: " ~ block.c[0][1].t) }}{%- endif -%} +" class=" +{%- if block.c[0][2].t == "Period" -%}ol-delim-period +{%- elif block.c[0][2].t == "OneParen" -%}ol-delim-oneparen +{%- elif block.c[0][2].t == "TwoParens" -%}ol-delim-twoparens +{%- else -%}{{ abort("Cannot render ordered list with delimtype: " ~ block.c[0][2].t) }}{%- endif -%} +"> +{{ render_listitems(meta, block.c[1]) }} +</ol> +{%- endmacro -%} + +{%- macro render_blockquote(meta, block) -%} +<blockquote> +{{ render_blocks(meta,block.c) }} +</blockquote> +{%- endmacro -%} + +{%- macro render_quoted(meta, block) -%} +{%- if block.c[0].t == "DoubleQuote" -%} +“{{ render_blocks(meta,block.c[1]) }}†+{%- elif block.c[0].t == "SingleQuote" -%} +‘{{ render_blocks(meta,block.c[1]) }}’ +{%- else -%} +{{ abort("Cannot render quoted with type: " ~ block.c[0].t) }} +{%- endif -%} +{%- endmacro -%} + +{%- macro render_strikeout(meta, block) -%} +<del>{{ render_blocks(meta,block.c) }}</del> +{%- endmacro -%} + +{%- macro render_subscript(meta, block) -%} +<sub>{{ render_blocks(meta,block.c) }}</sub> +{%- endmacro -%} + +{%- macro render_superscript(meta, block) -%} +<sup>{{ render_blocks(meta,block.c) }}</sup> +{%- endmacro -%} + +{%- macro render_footnote_link(meta, block) -%} +{%- set footnote_counter = footnote_counter + 1 -%} +<sup class="footnote-ref"><a title="Footnote {{ footnote_counter }}" id="fnref{{ footnote_counter }}" href="#fn{{ footnote_counter }}">[{{ footnote_counter }}]</a></sup> +{%- endmacro -%} + +{%- macro render_math(meta, block) -%} +{%- if block.c|length != 2 -%} +{{ abort("Refusing to render math with block.c|length == " ~ block.c|length ~ ":" ~ block|tojson() ) }} +{%- endif -%} +{%- if block.c[0].t == "DisplayMath" -%} +<div class="math display-math"> +{{ block.c[1] }} +</div> +{%- elif block.c[0].t == "InlineMath" -%} +<span class="math inline-math">{{ block.c[1] }}</span> +{%- else -%} +{{ abort("Cannot render math: " ~ block.c[0].t) }} +{%- endif -%} +{%- endmacro -%} + + + + + + + + +{%- if not footnote_counter is defined -%} +{%- set footnote_counter = 0 -%} +{%- endif -%} + diff --git a/theme/templates/site.html.j2 b/theme/templates/site.html.j2 new file mode 100644 index 0000000..5737ff4 --- /dev/null +++ b/theme/templates/site.html.j2 @@ -0,0 +1,60 @@ +<!DOCTYPE html> +{#- + data + settings + commit + blob + mimetype + native + filename +-#} +{%- import 'native.j2' as nt -%} +<html lang="en"> +<head> + <title>{{filename}}</title> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <!-- <base target="_blank"> --> + <!-- <meta HTTP-EQUIV="REFRESH" content="3; url=#">--> + <link rel="preload" href="/static/style.css" as="style"> + <link rel="stylesheet" type="text/css" href="/static/style.css"> + <!-- <link rel="icon" type="image/png" sizes="192x192" href="static/img/favicon-192x192.png"/> + <link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon-32x32.png"/>--> + <!-- <link rel="icon" type="image/x-icon" sizes="16x16" href="static/img/favicon.ico"/> --> +</head> +<body> + <header> + <label for="show-header-menu" class="show-header-menu">☰</label> + <input type="checkbox" id="show-header-menu" role="button"> + <label for="show-header-menu" class="show-header-menu-bg"> </label> + <nav> + <a href="/index.md"><img id="Logo" src="/resources/assets/banner-logo.png" alt="Home" /></a> + <a href="/Ãœber-uns.md">Ãœber uns</a> + <a href="/Fachgruppentreffen.md">Fachgruppentreffen</a> + <a href="/Cookie-Talks.md">Cookie Talks</a> + <a href="/Mentoring.md">Mentoring</a> + <a href="/studentische-Informatiktage-(sIT).md">studentische Informatiktage (sIT)</a> + </nav> + </header> + <!--<nav id="toc"> + </nav>--> + <main> + {{ nt.render(native) }} + <footer> + <span> + Last edited by <strong>{{commit.author.real.name|e}}</strong> + ({{commit.date.custom|e}}). <a href="https://gitlab.gwdg.de/GAUMI-fginfo/fg-website-data/-/edit/main/{{filename}}" target="_blank">[EDIT]</a> + </span> + </footer> + </main> + <footer> + <div> + <a href="https://asta.uni-goettingen.de/impressum/datenschutz/">Datenschutz</a> + <a href="/Impressum.md">Impressum</a> + <div> + <div>Fachgruppe Informatik Göttingen, 2022.</div> + <!-- blablabla datenschutz,impressum etc... --> + </footer> +</body> +<!-- The Cake Is A Lie! --> +</html> diff --git a/template.html b/theme/templates/template.html similarity index 100% rename from template.html rename to theme/templates/template.html -- GitLab