Add "minimal mode" to OML generator, omitting additional XML attributes and non-text nodes
This commit is contained in:
parent
e9e83da78b
commit
dffe13e9a7
2 changed files with 37 additions and 23 deletions
|
|
@ -1,12 +1,17 @@
|
||||||
// Warning: Generated code! Do not edit!
|
// Warning: Generated code! Do not edit!
|
||||||
// Input file: '{{inputfile}}'
|
// Input file: '{{inputfile}}'
|
||||||
// Generator: https://msdl.uantwerpen.be/git/jexelmans/xopp2py
|
// Generator: https://msdl.uantwerpen.be/git/jexelmans/xopp2py
|
||||||
|
{%- if minimal %}
|
||||||
|
// Minimal mode enabled: All XML attributes and non-text nodes are omitted.
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
||||||
|
|
||||||
uses <{{namespaces.xopp}}#> as xopp
|
uses <{{namespaces.xopp}}#> as xopp
|
||||||
uses <{{namespaces.object_diagram}}#> as object_diagram
|
uses <{{namespaces.object_diagram}}#> as object_diagram
|
||||||
|
{%- if not minimal %}
|
||||||
uses <{{namespaces.dict}}#> as dict
|
uses <{{namespaces.dict}}#> as dict
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
ci model : xopp:Model []
|
ci model : xopp:Model []
|
||||||
|
|
||||||
|
|
@ -20,7 +25,8 @@ description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
||||||
object_diagram:inModel model
|
object_diagram:inModel model
|
||||||
]
|
]
|
||||||
|
|
||||||
{% for page_index, page in enumerate(file.pages) %}
|
{%- for page_index, page in enumerate(file.pages) %}
|
||||||
|
|
||||||
ci p{{page_index}} : xopp:Page [
|
ci p{{page_index}} : xopp:Page [
|
||||||
xopp:hasWidth {{ page.width }}
|
xopp:hasWidth {{ page.width }}
|
||||||
xopp:hasHeight {{ page.height }}
|
xopp:hasHeight {{ page.height }}
|
||||||
|
|
@ -31,28 +37,35 @@ description <{{namespaces.description}}#> as {{namespaces.shorthand}} {
|
||||||
object_diagram:inModel model
|
object_diagram:inModel model
|
||||||
]
|
]
|
||||||
|
|
||||||
{%- for layer_index, layer in enumerate(page.layers) %}
|
{%- for layer_index, layer in enumerate(page.layers) %}
|
||||||
ci p{{page_index}}l{{layer_index}} : xopp:Layer [
|
|
||||||
xopp:inPage p{{page_index}}
|
|
||||||
object_diagram:inModel model
|
|
||||||
]
|
|
||||||
|
|
||||||
{%- for el_index, el in enumerate(layer.elements) %}
|
ci p{{page_index}}l{{layer_index}} : xopp:Layer [
|
||||||
ci p{{page_index}}l{{layer_index}}e{{el_index}} : xopp:{{el.__class__.__name__}} [
|
xopp:inPage p{{page_index}}
|
||||||
xopp:hasText {{el.text | to_oml_string_literal}}
|
object_diagram:inModel model
|
||||||
xopp:inLayer p{{page_index}}l{{layer_index}}
|
]
|
||||||
object_diagram:inModel model
|
|
||||||
]
|
|
||||||
|
|
||||||
{%- for key, value in el.attributes.items() %}
|
{%- for el_index, el in enumerate(layer.elements) %}
|
||||||
ci p{{page_index}}l{{layer_index}}e{{el_index}}a{{loop.index}} : xopp:XMLAttribute [
|
{%- if not minimal or el.__class__.__name__ == "Text" %}
|
||||||
dict:hasKey {{key | to_oml_string_literal}}
|
|
||||||
dict:hasValue {{value | to_oml_string_literal}}
|
ci p{{page_index}}l{{layer_index}}e{{el_index}} : xopp:{{el.__class__.__name__}} [
|
||||||
xopp:ofLayerElement p{{page_index}}l{{layer_index}}e{{el_index}}
|
xopp:hasText {{el.text | to_oml_string_literal}}
|
||||||
object_diagram:inModel model
|
xopp:inLayer p{{page_index}}l{{layer_index}}
|
||||||
]
|
object_diagram:inModel model
|
||||||
{% endfor %}
|
]
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
{%- if not minimal %}
|
||||||
{% endfor %}
|
{%- for key, value in el.attributes.items() %}
|
||||||
|
|
||||||
|
ci p{{page_index}}l{{layer_index}}e{{el_index}}a{{loop.index}} : xopp:XMLAttribute [
|
||||||
|
dict:hasKey {{key | to_oml_string_literal}}
|
||||||
|
dict:hasValue {{value | to_oml_string_literal}}
|
||||||
|
xopp:ofLayerElement p{{page_index}}l{{layer_index}}e{{el_index}}
|
||||||
|
object_diagram:inModel model
|
||||||
|
]
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endfor %}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ def writeOML(xournalFile: abstract_syntax.XournalFile, inputfile:str, namespace:
|
||||||
|
|
||||||
template = environment.get_template("template.oml")
|
template = environment.get_template("template.oml")
|
||||||
for piece in template.generate(
|
for piece in template.generate(
|
||||||
|
minimal=True,
|
||||||
file=xournalFile,
|
file=xournalFile,
|
||||||
inputfile=inputfile,
|
inputfile=inputfile,
|
||||||
enumerate=enumerate,
|
enumerate=enumerate,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue