isodoc 1.6.7.1 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +1 -1
  3. data/lib/isodoc-yaml/i18n-ar.yaml +19 -25
  4. data/lib/isodoc-yaml/i18n-de.yaml +1 -0
  5. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  6. data/lib/isodoc-yaml/i18n-es.yaml +1 -0
  7. data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
  8. data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
  9. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  10. data/lib/isodoc.rb +1 -0
  11. data/lib/isodoc/convert.rb +1 -1
  12. data/lib/isodoc/css.rb +3 -3
  13. data/lib/isodoc/function/blocks.rb +180 -168
  14. data/lib/isodoc/function/form.rb +39 -36
  15. data/lib/isodoc/function/inline.rb +5 -1
  16. data/lib/isodoc/function/reqt.rb +91 -85
  17. data/lib/isodoc/function/to_word_html.rb +207 -204
  18. data/lib/isodoc/html_convert.rb +0 -4
  19. data/lib/isodoc/html_function/form.rb +48 -45
  20. data/lib/isodoc/html_function/html.rb +2 -0
  21. data/lib/isodoc/html_function/postprocess.rb +9 -4
  22. data/lib/isodoc/presentation_function/block.rb +7 -4
  23. data/lib/isodoc/presentation_function/inline.rb +29 -12
  24. data/lib/isodoc/presentation_function/section.rb +1 -2
  25. data/lib/isodoc/presentation_xml_convert.rb +2 -2
  26. data/lib/isodoc/version.rb +1 -1
  27. data/lib/isodoc/xref.rb +8 -7
  28. data/lib/isodoc/xref/xref_anchor.rb +45 -44
  29. data/lib/isodoc/xref/xref_counter.rb +113 -103
  30. data/lib/isodoc/xref/xref_gen.rb +39 -11
  31. data/lib/metanorma/output.rb +7 -0
  32. data/lib/metanorma/output/base.rb +13 -0
  33. data/lib/metanorma/output/utils.rb +17 -0
  34. data/lib/metanorma/output/xslfo.rb +21 -0
  35. data/spec/assets/outputtest/a.xml +66 -0
  36. data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
  37. data/spec/isodoc/blocks_spec.rb +358 -243
  38. data/spec/isodoc/form_spec.rb +94 -90
  39. data/spec/isodoc/inline_spec.rb +413 -234
  40. data/spec/isodoc/postproc_spec.rb +70 -27
  41. data/spec/isodoc/terms_spec.rb +2 -2
  42. data/spec/isodoc/xref_spec.rb +274 -652
  43. metadata +8 -18
  44. data/lib/isodoc/html_function/sectionsplit.rb +0 -230
  45. data/spec/isodoc/sectionsplit_spec.rb +0 -190
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17e14b978b65a7667074ab1dff17bd5dc76a58e6baf7ace593407dc921ddf558
4
- data.tar.gz: 3622549bc44570ec6e8de62fb55a62af937e32306ccc444bfaf0a1063caae511
3
+ metadata.gz: 69357a32a0ea52a4575c37f79a94d8c0108a9a2f84654ce4dcbd58a472020b80
4
+ data.tar.gz: 02605ddddc513099f73d724c0afffe084cbd6de3ad13cf4267d23772697f839d
5
5
  SHA512:
6
- metadata.gz: 2cffca2a878c9bc3e05d26b85edb21be9ff27a75b8fd6e9ab7b31cdb861915b41baeb9e4b4027fb5f8f5e751879143dd55ea7cc35d46d6feb507d2a83632ff2b
7
- data.tar.gz: 5146c2a8457a5f41232b6176acb3bf5fd77bfb75941b9030f6c015463cfe7646e6a3df153423229a3c9a17e0aa6c02529062bffdd1e98ad116fb91f1d61f6306
6
+ metadata.gz: 4b35bc0f9b1fda5a62971decf1106655c8b7170dde78a8609b93cfeeafa800feceba3575fb4ed220eb117bf763d04de43786ea6843182bfda1b41b4fc271ae90
7
+ data.tar.gz: 9a904c7285684c64b387654397d29a64db4e24604e68bb7a07a5c86c853eb89607b515aa47a8f59f5d6c4e08b0ffcf5f9381ae95e8a219060edd0c021cbe822a
data/isodoc.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "html2doc", "~> 1.1.1"
33
33
  spec.add_dependency "htmlentities", "~> 4.3.4"
34
34
  spec.add_dependency "liquid", "~> 4"
35
- spec.add_dependency "metanorma", ">= 1.2.0"
35
+ #spec.add_dependency "metanorma", ">= 1.2.0"
36
36
  spec.add_dependency "nokogiri", "~> 1.11.0"
37
37
  spec.add_dependency "relaton-cli"
38
38
  spec.add_dependency "roman-numerals"
@@ -18,29 +18,23 @@ clause: فقرة
18
18
  annex: ملحق
19
19
  appendix: تذييل
20
20
  no_terms_boilerplate: |
21
- <p>No terms and definitions are listed in this document.</p>
21
+ <p>لم يتم سرد أي مصطلحات وتعريفات في هذا المستند.</p>
22
22
  internal_terms_boilerplate: |
23
- <p>For the purposes of this document,
24
- the following terms and definitions apply.</p>
23
+ <p>لأغراض هذا المستند، تنطبق المصطلحات والتعريفات التالية.</p>
25
24
  norm_with_refs_pref:
26
- The following documents are referred to in the text in such a way
27
- that some or all of their content constitutes requirements of this
28
- document. For dated references, only the edition cited applies.
29
- For undated references, the latest edition of the referenced
30
- document (including any amendments) applies.
25
+ تتم الإشارة إلى المستندات التالية في النص بحيث يشكل بعض أو كل محتوياتها متطلبات هذا المستند. للحصول على مراجع مؤرخة، تطبق النسخة المشار إليها فقط. بالنسبة للمراجع غير المؤرخة ، تنطبق أحدث طبعة من الوثيقة المشار إليها (بما في ذلك أي تعديلات).
31
26
  norm_empty_pref:
32
- There are no normative references in this document.
27
+ لا توجد مراجع معيارية في هذه الوثيقة.
33
28
  external_terms_boilerplate: |
34
- <p>For the purposes of this document,
35
- the terms and definitions given in % apply.</p>
29
+ <p> لأغراض هذا المستند ، تنطبق المصطلحات والتعريفات الواردة في%. </ p>
36
30
  internal_external_terms_boilerplate: |
37
- <p>For the purposes of this document, the terms and definitions
38
- given in % and the following apply.</p>
39
- term_defined_in: "[term defined in %]"
31
+ <p>لأغراض هذه الوثيقة ،تنطبق المصطلحات والتعاريف الواردة في % وما يلي.</p>
32
+ term_defined_in: "[المصطلح المحدد في %]"
40
33
  note: ملاحظة
41
34
  note_xref: ملاحظة
42
- termnote: Note % to entry
35
+ termnote: ملاحظة % للقيد
43
36
  list: قائمة
37
+ deflist: قائمة تعريف
44
38
  figure: شكل
45
39
  formula: معادلة
46
40
  inequality: عدم مساواة
@@ -48,16 +42,16 @@ table: جدول
48
42
  requirement: مطلب
49
43
  recommendation: توصية
50
44
  permission: إذن
51
- key: Key
45
+ key: مفتاح
52
46
  example: مثال
53
47
  example_xref: مثال
54
48
  where: حيث
55
49
  wholeoftext: كامل النص
56
- draft_label: draft
57
- inform_annex: informative
58
- norm_annex: normative
50
+ draft_label: مسودة
51
+ inform_annex: إخباري
52
+ norm_annex: مقياسي
59
53
  modified: معدلة
60
- deprecated: DEPRECATED
54
+ deprecated: مهمل
61
55
  source: مصدر
62
56
  and: و
63
57
  all_parts: كل الأجزاء
@@ -78,8 +72,8 @@ subject: موضوع
78
72
  inherits: يرث
79
73
  admonition:
80
74
  danger: خطر
81
- warning: Warning
82
- caution: Caution
75
+ warning: تحذير
76
+ caution: حذر
83
77
  important: مهم
84
78
  safety precautions: احتياطات السلامة
85
79
  locality:
@@ -108,9 +102,9 @@ inflection:
108
102
  ملاحظة:
109
103
  sg: ملاحظة
110
104
  pl: ملاحظات
111
- "Note % to entry":
112
- sg: Note % to entry
113
- pl: Notes % to entry
105
+ "ملاحظة % للقيد":
106
+ sg: ملاحظة % للقيد
107
+ pl: ملاحظات % للقيد
114
108
  قائمة:
115
109
  sg: قائمة
116
110
  pl: قوائم
@@ -36,6 +36,7 @@ note: HINWEIS
36
36
  note_xref: Hinweis
37
37
  termnote: Hinweis % zum Eintrag
38
38
  list: Liste
39
+ deflist: Definitionsliste
39
40
  figure: Abbildung
40
41
  formula: Formel
41
42
  inequality: Formel
@@ -42,6 +42,7 @@ note: NOTE
42
42
  note_xref: Note
43
43
  termnote: Note % to entry
44
44
  list: List
45
+ deflist: Definition List
45
46
  figure: Figure
46
47
  formula: Formula
47
48
  inequality: Formula
@@ -38,6 +38,7 @@ note: NOTA
38
38
  note_xref: Nota
39
39
  termnote: Nota % a la entrada
40
40
  list: Lista
41
+ deflist: Lista de definiciones
41
42
  figure: Figura
42
43
  formula: Fórmula
43
44
  inequality: Fórmula
@@ -38,6 +38,7 @@ figure: Figure
38
38
  formula: Formule
39
39
  inequality: Formule
40
40
  list: Liste
41
+ deflist: Liste de définitions
41
42
  table: Tableau
42
43
  requirement: Exigence
43
44
  recommendation: Recommandation
@@ -41,6 +41,7 @@ note: ПРИМЕЧАНИЕ
41
41
  note_xref: Примечание
42
42
  termnote: Примечание % к определению
43
43
  list: Список
44
+ deflist: Список определений
44
45
  figure: Рисунок
45
46
  formula: Формула
46
47
  inequality: Формула
@@ -40,6 +40,7 @@ figure: 图
40
40
  formula: 公式
41
41
  inequality: 公式
42
42
  list: 列项
43
+ deflist: 定义列表
43
44
  table: 表
44
45
  requirement: 要求
45
46
  recommendation: 建议
data/lib/isodoc.rb CHANGED
@@ -23,6 +23,7 @@ require "isodoc/headlesshtml_convert"
23
23
  require "isodoc/presentation_xml_convert"
24
24
  require "isodoc/xref"
25
25
  require "isodoc/i18n"
26
+ require "metanorma/output"
26
27
 
27
28
  module IsoDoc
28
29
  end
@@ -145,7 +145,7 @@ module IsoDoc
145
145
  end
146
146
 
147
147
  def convert_init(file, input_filename, debug)
148
- docxml = Nokogiri::XML(file)
148
+ docxml = Nokogiri::XML(file) { |config| config.huge }
149
149
  filename, dir = init_file(input_filename, debug)
150
150
  docxml.root.default_namespace = ""
151
151
  lang = docxml&.at(ns("//bibdata/language"))&.text and @lang = lang
data/lib/isodoc/css.rb CHANGED
@@ -39,7 +39,7 @@ module IsoDoc
39
39
  {
40
40
  bodyfont: "Arial",
41
41
  headerfont: "Arial",
42
- monospacefont: "Courier",
42
+ monospacefont: "Courier New",
43
43
  }
44
44
  end
45
45
 
@@ -53,7 +53,7 @@ module IsoDoc
53
53
  {
54
54
  "bodyfont" => options[:bodyfont] || "Arial",
55
55
  "headerfont" => options[:headerfont] || "Arial",
56
- "monospacefont" => options[:monospacefont] || "Courier",
56
+ "monospacefont" => options[:monospacefont] || "Courier New",
57
57
  "normalfontsize" => options[:normalfontsize],
58
58
  "monospacefontsize" => options[:monospacefontsize],
59
59
  "smallerfontsize" => options[:smallerfontsize],
@@ -64,7 +64,7 @@ module IsoDoc
64
64
  def scss_fontheader(is_html_css)
65
65
  b = options[:bodyfont] || "Arial"
66
66
  h = options[:headerfont] || "Arial"
67
- m = options[:monospacefont] || "Courier"
67
+ m = options[:monospacefont] || "Courier New"
68
68
  ns = options[:normalfontsize] || (is_html_css ? "1.0em" : "12.0pt")
69
69
  ms = options[:monospacefontsize] || (is_html_css ? "0.8em" : "11.0pt")
70
70
  ss = options[:smallerfontsize] || (is_html_css ? "0.9em" : "10.0pt")
@@ -1,231 +1,243 @@
1
1
  require_relative "blocks_example_note"
2
2
 
3
- module IsoDoc::Function
4
- module Blocks
5
- @annotation = false
3
+ module IsoDoc
4
+ module Function
5
+ module Blocks
6
+ @annotation = false
6
7
 
7
- def middle_title(_isoxml, out)
8
- out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
9
- end
8
+ def middle_title(_isoxml, out)
9
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
10
+ end
10
11
 
11
- def middle_admonitions(isoxml, out)
12
- isoxml.xpath(ns("//sections/note | //sections/admonition")).each do |x|
13
- parse(x, out)
12
+ def middle_admonitions(isoxml, out)
13
+ isoxml.xpath(ns("//sections/note | //sections/admonition")).each do |x|
14
+ parse(x, out)
15
+ end
14
16
  end
15
- end
16
17
 
17
- def figure_name_parse(_node, div, name)
18
- return if name.nil?
18
+ def figure_name_parse(_node, div, name)
19
+ return if name.nil?
19
20
 
20
- div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
21
- name.children.each { |n| parse(n, p) }
21
+ div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
22
+ name.children.each { |n| parse(n, p) }
23
+ end
22
24
  end
23
- end
24
25
 
25
- def figure_key(out)
26
- out.p **{ style: "page-break-after:avoid;"} do |p|
27
- p.b { |b| b << @i18n.key }
26
+ def figure_key(out)
27
+ out.p **{ style: "page-break-after:avoid;" } do |p|
28
+ p.b { |b| b << @i18n.key }
29
+ end
28
30
  end
29
- end
30
31
 
31
- def figure_attrs(node)
32
- attr_code(id: node["id"], class: "figure", style: keep_style(node))
33
- end
32
+ def figure_attrs(node)
33
+ attr_code(id: node["id"], class: "figure", style: keep_style(node))
34
+ end
34
35
 
35
- def figure_parse(node, out)
36
- return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
37
- node["type"] == "pseudocode"
36
+ def figure_parse(node, out)
37
+ return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
38
+ node["type"] == "pseudocode"
39
+
40
+ @in_figure = true
41
+ figure_parse1(node, out)
42
+ @in_figure = false
43
+ end
38
44
 
39
- @in_figure = true
40
- out.div **figure_attrs(node) do |div|
41
- node.children.each do |n|
42
- figure_key(out) if n.name == "dl"
43
- parse(n, div) unless n.name == "name"
45
+ def figure_parse1(node, out)
46
+ out.div **figure_attrs(node) do |div|
47
+ node.children.each do |n|
48
+ figure_key(out) if n.name == "dl"
49
+ parse(n, div) unless n.name == "name"
50
+ end
51
+ figure_name_parse(node, div, node.at(ns("./name")))
44
52
  end
45
- figure_name_parse(node, div, node.at(ns("./name")))
46
53
  end
47
- @in_figure = false
48
- end
49
54
 
50
- def pseudocode_attrs(node)
51
- attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
52
- end
55
+ def pseudocode_attrs(node)
56
+ attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
57
+ end
53
58
 
54
- def pseudocode_parse(node, out)
55
- @in_figure = true
56
- name = node.at(ns("./name"))
57
- out.div **pseudocode_attrs(node) do |div|
58
- node.children.each { |n| parse(n, div) unless n.name == "name" }
59
- sourcecode_name_parse(node, div, name)
59
+ def pseudocode_parse(node, out)
60
+ @in_figure = true
61
+ name = node.at(ns("./name"))
62
+ out.div **pseudocode_attrs(node) do |div|
63
+ node.children.each { |n| parse(n, div) unless n.name == "name" }
64
+ sourcecode_name_parse(node, div, name)
65
+ end
66
+ @in_figure = false
60
67
  end
61
- @in_figure = false
62
- end
63
68
 
64
- def sourcecode_name_parse(node, div, name)
65
- return if name.nil?
69
+ def sourcecode_name_parse(_node, div, name)
70
+ return if name.nil?
66
71
 
67
- div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
68
- name.children.each { |n| parse(n, p) }
72
+ div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
73
+ name.children.each { |n| parse(n, p) }
74
+ end
69
75
  end
70
- end
71
76
 
72
- def admonition_name_parse(_node, div, name)
73
- div.p **{ class: "AdmonitionTitle", style: "text-align:center;" } do |p|
74
- name.children.each { |n| parse(n, p) }
77
+ def admonition_name_parse(_node, div, name)
78
+ div.p **{ class: "AdmonitionTitle", style: "text-align:center;" } do |p|
79
+ name.children.each { |n| parse(n, p) }
80
+ end
75
81
  end
76
- end
77
82
 
78
- def sourcecode_attrs(node)
79
- attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
80
- end
83
+ def sourcecode_attrs(node)
84
+ attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
85
+ end
81
86
 
82
- def sourcecode_parse(node, out)
83
- name = node.at(ns("./name"))
84
- out.p **sourcecode_attrs(node) do |div|
85
- @sourcecode = true
86
- node.children.each { |n| parse(n, div) unless n.name == "name" }
87
- @sourcecode = false
87
+ def sourcecode_parse(node, out)
88
+ name = node.at(ns("./name"))
89
+ out.p **sourcecode_attrs(node) do |div|
90
+ @sourcecode = true
91
+ node.children.each { |n| parse(n, div) unless n.name == "name" }
92
+ @sourcecode = false
93
+ end
94
+ sourcecode_name_parse(node, out, name)
88
95
  end
89
- sourcecode_name_parse(node, out, name)
90
- end
91
96
 
92
- def pre_parse(node, out)
93
- out.pre node.text, **attr_code(id: node["id"])
94
- end
97
+ def pre_parse(node, out)
98
+ out.pre node.text, **attr_code(id: node["id"])
99
+ end
95
100
 
96
- def annotation_parse(node, out)
97
- @sourcecode = false
98
- @annotation = true
99
- node.at("./preceding-sibling::*[local-name() = 'annotation']") or
100
- out << "<br/>"
101
- callout = node.at(ns("//callout[@target='#{node['id']}']"))
102
- out << "<br/>&lt;#{callout.text}&gt; "
103
- out << node&.children&.text&.strip
104
- @annotation = false
105
- end
101
+ def annotation_parse(node, out)
102
+ @sourcecode = false
103
+ @annotation = true
104
+ node.at("./preceding-sibling::*[local-name() = 'annotation']") or
105
+ out << "<br/>"
106
+ callout = node.at(ns("//callout[@target='#{node['id']}']"))
107
+ out << "<br/>&lt;#{callout.text}&gt; "
108
+ out << node&.children&.text&.strip
109
+ @annotation = false
110
+ end
106
111
 
107
- def admonition_class(_node)
108
- "Admonition"
109
- end
112
+ def admonition_class(_node)
113
+ "Admonition"
114
+ end
110
115
 
111
- def admonition_name(node, type)
112
- name = node&.at(ns("./name")) and return name
113
- name = Nokogiri::XML::Node.new("name", node.document)
114
- return unless type && @i18n.admonition[type]
116
+ def admonition_name(node, type)
117
+ name = node&.at(ns("./name")) and return name
118
+ name = Nokogiri::XML::Node.new("name", node.document)
119
+ return unless type && @i18n.admonition[type]
115
120
 
116
- name << @i18n.admonition[type]&.upcase
117
- name
118
- end
121
+ name << @i18n.admonition[type]&.upcase
122
+ name
123
+ end
119
124
 
120
- def admonition_attrs(node)
121
- attr_code(id: node["id"], class: admonition_class(node),
122
- style: keep_style(node))
123
- end
125
+ def admonition_attrs(node)
126
+ attr_code(id: node["id"], class: admonition_class(node),
127
+ style: keep_style(node))
128
+ end
124
129
 
125
- def admonition_parse(node, out)
126
- type = node["type"]
127
- name = admonition_name(node, type)
128
- out.div **admonition_attrs(node) do |t|
129
- admonition_name_parse(node, t, name) if name
130
- node.children.each { |n| parse(n, t) unless n.name == "name" }
130
+ def admonition_parse(node, out)
131
+ type = node["type"]
132
+ name = admonition_name(node, type)
133
+ out.div **admonition_attrs(node) do |t|
134
+ admonition_name_parse(node, t, name) if name
135
+ node.children.each { |n| parse(n, t) unless n.name == "name" }
136
+ end
131
137
  end
132
- end
133
138
 
134
- def formula_where(dl, out)
135
- return unless dl
139
+ def formula_where(dlist, out)
140
+ return unless dlist
136
141
 
137
- out.p **{ style: "page-break-after:avoid;" } do |p|
138
- p << @i18n.where
142
+ out.p **{ style: "page-break-after:avoid;" } do |p|
143
+ p << @i18n.where
144
+ end
145
+ parse(dlist, out)
146
+ out.parent.at("./dl")["class"] = "formula_dl"
139
147
  end
140
- parse(dl, out)
141
- out.parent.at("./dl")["class"] = "formula_dl"
142
- end
143
148
 
144
- def formula_parse1(node, out)
145
- out.div **attr_code(class: "formula") do |div|
146
- div.p do |p|
147
- parse(node.at(ns("./stem")), div)
148
- if lbl = node&.at(ns("./name"))&.text
149
- insert_tab(div, 1)
150
- div << "(#{lbl})"
149
+ def formula_parse1(node, out)
150
+ out.div **attr_code(class: "formula") do |div|
151
+ div.p do |_p|
152
+ parse(node.at(ns("./stem")), div)
153
+ if lbl = node&.at(ns("./name"))&.text
154
+ insert_tab(div, 1)
155
+ div << "(#{lbl})"
156
+ end
151
157
  end
152
158
  end
153
159
  end
154
- end
155
160
 
156
- def formula_attrs(node)
157
- attr_code(id: node["id"], style: keep_style(node))
158
- end
161
+ def formula_attrs(node)
162
+ attr_code(id: node["id"], style: keep_style(node))
163
+ end
159
164
 
160
- def formula_parse(node, out)
161
- out.div **formula_attrs(node) do |div|
162
- formula_parse1(node, div)
163
- formula_where(node.at(ns("./dl")), div)
164
- node.children.each do |n|
165
- next if %w(stem dl name).include? n.name
165
+ def formula_parse(node, out)
166
+ out.div **formula_attrs(node) do |div|
167
+ formula_parse1(node, div)
168
+ formula_where(node.at(ns("./dl")), div)
169
+ node.children.each do |n|
170
+ next if %w(stem dl name).include? n.name
166
171
 
167
- parse(n, div)
172
+ parse(n, div)
173
+ end
168
174
  end
169
175
  end
170
- end
171
176
 
172
- def para_class(_node)
173
- classtype = nil
174
- classtype = "MsoCommentText" if in_comment
175
- classtype = "Sourcecode" if @annotation
176
- classtype
177
- end
177
+ def para_class(_node)
178
+ classtype = nil
179
+ classtype = "MsoCommentText" if in_comment
180
+ classtype = "Sourcecode" if @annotation
181
+ classtype
182
+ end
178
183
 
179
- def para_attrs(node)
180
- attrs = { class: para_class(node), id: node["id"] }
181
- s = node["align"].nil? ? "" : "text-align:#{node['align']};"
182
- s = "#{s}#{keep_style(node)}"
183
- attrs[:style] = s unless s.empty?
184
- attrs
185
- end
184
+ def para_attrs(node)
185
+ attrs = { class: para_class(node), id: node["id"] }
186
+ s = node["align"].nil? ? "" : "text-align:#{node['align']};"
187
+ s = "#{s}#{keep_style(node)}"
188
+ attrs[:style] = s unless s.empty?
189
+ attrs
190
+ end
186
191
 
187
- def para_parse(node, out)
188
- out.p **attr_code(para_attrs(node)) do |p|
189
- unless @termdomain.empty?
190
- p << "&lt;#{@termdomain}&gt; "
191
- @termdomain = ""
192
+ def para_parse(node, out)
193
+ out.p **attr_code(para_attrs(node)) do |p|
194
+ unless @termdomain.empty?
195
+ p << "&lt;#{@termdomain}&gt; "
196
+ @termdomain = ""
197
+ end
198
+ node.children.each { |n| parse(n, p) }
192
199
  end
193
- node.children.each { |n| parse(n, p) }
194
200
  end
195
- end
196
201
 
197
- def quote_attribution(node, out)
198
- author = node.at(ns("./author"))
199
- source = node.at(ns("./source"))
200
- return if author.nil? && source.nil?
202
+ def quote_attribution(node, out)
203
+ author = node.at(ns("./author"))
204
+ source = node.at(ns("./source"))
205
+ return if author.nil? && source.nil?
201
206
 
202
- out.p **{ class: "QuoteAttribution" } do |p|
203
- p << "&mdash; #{author.text}" if author
204
- p << ", " if author && source
205
- eref_parse(source, p) if source
207
+ out.p **{ class: "QuoteAttribution" } do |p|
208
+ p << "&mdash; #{author.text}" if author
209
+ p << ", " if author && source
210
+ eref_parse(source, p) if source
211
+ end
206
212
  end
207
- end
208
213
 
209
- def quote_parse(node, out)
210
- attrs = para_attrs(node)
211
- attrs[:class] = "Quote"
212
- out.div **attr_code(attrs) do |p|
213
- node.children.each do |n|
214
- parse(n, p) unless ["author", "source"].include? n.name
214
+ def quote_parse(node, out)
215
+ attrs = para_attrs(node)
216
+ attrs[:class] = "Quote"
217
+ out.div **attr_code(attrs) do |p|
218
+ node.children.each do |n|
219
+ parse(n, p) unless %w(author source).include? n.name
220
+ end
221
+ quote_attribution(node, out)
215
222
  end
216
- quote_attribution(node, out)
217
223
  end
218
- end
219
224
 
220
- def passthrough_parse(node, out)
221
- return if node["format"] &&
222
- !(node["format"].split(/,/).include? @format.to_s)
225
+ def passthrough_parse(node, out)
226
+ return if node["format"] &&
227
+ !(node["format"].split(",").include? @format.to_s)
223
228
 
224
- out.passthrough node.text
225
- end
229
+ out.passthrough node.text
230
+ end
226
231
 
227
- def svg_parse(node, out)
228
- out << node.to_xml
232
+ def svg_parse(node, out)
233
+ out.parent.add_child(node)
234
+ end
235
+
236
+ def toc_parse(node, out)
237
+ out.div **{ class: "toc" } do |div|
238
+ node.children.each { |n| parse(n, div) }
239
+ end
240
+ end
229
241
  end
230
242
  end
231
243
  end