-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmacros.tera.xml
70 lines (65 loc) · 2.43 KB
/
macros.tera.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{# -*- mode: web; -*- #}
{% macro any_segment(segment) %}
{% if segment.type == "LineBreak" %}
<lb n="{{segment.index}}"/>
{% elif segment.type == "PageBreak" %}
<pb facs="drs:page{{segment.index}}"/>
{% elif segment.type == "Phrase" %}
{{ self::phrase(segment=segment) }}
{% elif segment.type == "Block" %}
{{ self::block(segment=segment) }}
{% elif segment.type == "Word" %}
{{ self::word(segment=segment) }}
{% endif %}
{% endmacro any_segment %}
{% macro word(segment) %}
<w xml:id="w{{segment.position.index}}" lemmaRef="lex:id">
{% if segment.simplePhonetics or segment.phonemic or segment.morphemicSegmentation or segment.morphemeGloss or segment.englishGloss %}
<choice>
<orig>{{segment.source | convert_breaks(lb=segment.lineBreak, pb=segment.pageBreak) | safe}}</orig>
{% if segment.simplePhonetics %}
<seg type="simple_phonetics">{{segment.simplePhonetics}}</seg>
{% endif %}
{% if segment.phonemic %}
<seg type="phonemic_form">{{segment.phonemic}}</seg>
{% endif %}
{% if segment.morphemicSegmentation | first %}
<seg type="morphemic_segmentation">{{segment.morphemicSegmentation | join(sep="-")}}</seg>
{% endif %}
{% if segment.morphemeGloss | first %}
<seg type="morphemic_gloss">{{segment.morphemeGloss | join(sep="-")}}</seg>
{% endif %}
{% if segment.englishGloss %}
<seg type="gloss">{{segment.englishGloss | join(sep=", ")}}</seg>
{% endif %}
</choice>
{% else %}
{{segment.source | convert_breaks(lb=segment.lineBreak, pb=segment.pageBreak) | safe}}
{% endif %}
</w>
{% endmacro word %}
{% macro phrase(segment) %}
<phr xml:id="p{{segment.index}}">
{% for child in segment.parts %}
{{ self::any_segment(segment=child) }}
{% endfor %}
</phr>
{% endmacro phrase %}
{% macro block(segment) %}
<ab xml:id="b{{segment.index}}" corresp="#b{{segment.index}}_trans">
{% for child in segment.parts %}
{{ self::any_segment(segment=child) }}
{% endfor %}
</ab>
{% endmacro phrase %}
{% macro commentary(segment) %}
{% if segment.type == "Word" and segment.commentary %}
<note target="#w{{segment.position.index}}">
{{segment.commentary}}
</note>
{% elif segment.parts %}
{% for segment in segment.parts %}
{{ self::commentary(segment=segment) }}
{% endfor %}
{% endif %}
{% endmacro commentary %}