Skip to content
Snippets Groups Projects
Commit dd265458 authored by Jake's avatar Jake
Browse files

implemented definition lists

parent ce941bb1
No related branches found
No related tags found
No related merge requests found
Pipeline #314825 passed
......@@ -308,6 +308,28 @@ class BlockContainer(Block): # Attr [Block]
self.content = self.parse_blocks(pandocraw[1])
# TODO handle alerts
class BlockDefinitionList(Block): # [([Inline], [[Block]])]
etype = "definitionlist"
def parse_internal(self, pandocraw):
"""
[
[
[{'t': 'Str', 'c': 'AStA'}],
[
[{'t': 'Plain', 'c': [{'t': 'Str', 'c': 'Allgemeiner'}, {'t': 'Space'}, {'t': 'Str', 'c': 'studierenden'}, {'t': 'Space'}, {'t': 'Str', 'c': 'Ausschuss'}]}]
]
]
]
"""
self.items = []
for rawitem in pandocraw:
item = {}
item["term"] = self.parse_inlines(rawitem[0])
item["definitions"] = []
for rawdefinition in rawitem[1]:
item["definitions"].append(self.parse_blocks(rawdefinition))
self.items.append(item)
############################## INLINE #########################################
class Inline(Element):
......@@ -425,7 +447,7 @@ block_parsing_register = {
"OrderedList" : BlockOrderedList,
"HorizontalRule": BlockHorizontalRule,
"Table" : {"TODO": True,}, # Attr Caption [ColSpec] TableHead [TableBody] TableFoot
"DefinitionList": {"TODO": True,}, # [([Inline], [[Block]])]
"DefinitionList": BlockDefinitionList,
#"LineBlock" :{"type":"lineblock", "TODO": True, "c" : [] }, # [[Inline]] # TODO find file that triggers LineBlock
#"Null" :{"type":"nothing" }, # TODO find file that triggers Null
}
......
......@@ -410,6 +410,18 @@ sup {
margin: 0 0 1em 0;
}
.content dt {
font-weight: bold;
}
.content dt::after {
content: ': '
}
.content dd {
margin-left: 1em;
margin-bottom: 0.1em;
}
.content ul,
.content ol {
padding-left: 2em;
......
......@@ -118,6 +118,8 @@
{{ render_block_rawblock(block, lang) }}
{%- elif etype == "orderedlist" -%}
{{ render_block_orderedlist(block, lang) }}
{%- elif etype == "definitionlist" -%}
{{ render_block_definitionlist(block, lang) }}
{%- else -%}
<br><strong>ERROR: Unhandled block type: '{{ etype|e }}'</strong><br>
{%- endif -%}
......@@ -208,6 +210,20 @@
</ol>
{%- endmacro -%}
{%- macro render_block_definitionlist(block, lang) -%}
{%- set items = block['items'] -%}
<dl>
{%- for item in items -%}
{%- set term = item['term'] -%}
{%- set definitions = item['definitions'] -%}
<dt>{{ render_inlines(term, lang) }}</dt>
{%- for def in definitions -%}
<dd>{{ render_blocks(def, lang) }}</dd>
{%- endfor -%}
{%- endfor -%}
</dl>
{%- endmacro -%}
{#- ############################ INLINES ################################## -#}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment