isodoc 1.0.25 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +12 -2
  3. data/.github/workflows/ubuntu.yml +15 -3
  4. data/.github/workflows/windows.yml +12 -2
  5. data/isodoc.gemspec +2 -2
  6. data/lib/isodoc.rb +2 -0
  7. data/lib/isodoc/common.rb +0 -4
  8. data/lib/isodoc/convert.rb +18 -8
  9. data/lib/isodoc/function/blocks.rb +46 -52
  10. data/lib/isodoc/function/blocks_example_note.rb +108 -0
  11. data/lib/isodoc/function/cleanup.rb +14 -2
  12. data/lib/isodoc/function/i18n.rb +1 -0
  13. data/lib/isodoc/function/inline.rb +76 -82
  14. data/lib/isodoc/function/inline_simple.rb +72 -0
  15. data/lib/isodoc/function/lists.rb +12 -6
  16. data/lib/isodoc/function/references.rb +49 -53
  17. data/lib/isodoc/function/reqt.rb +14 -5
  18. data/lib/isodoc/function/section.rb +10 -12
  19. data/lib/isodoc/function/table.rb +4 -5
  20. data/lib/isodoc/function/terms.rb +3 -3
  21. data/lib/isodoc/function/to_word_html.rb +22 -12
  22. data/lib/isodoc/function/utils.rb +9 -3
  23. data/lib/isodoc/headlesshtml_convert.rb +12 -6
  24. data/lib/isodoc/html_convert.rb +7 -1
  25. data/lib/isodoc/html_function/footnotes.rb +1 -1
  26. data/lib/isodoc/html_function/html.rb +16 -1
  27. data/lib/isodoc/html_function/postprocess.rb +6 -5
  28. data/lib/isodoc/metadata.rb +6 -0
  29. data/lib/isodoc/metadata_date.rb +19 -7
  30. data/lib/isodoc/pdf_convert.rb +13 -6
  31. data/lib/isodoc/presentation_xml_convert.rb +29 -0
  32. data/lib/isodoc/version.rb +1 -1
  33. data/lib/isodoc/word_convert.rb +7 -1
  34. data/lib/isodoc/word_function/body.rb +14 -48
  35. data/lib/isodoc/word_function/footnotes.rb +1 -1
  36. data/lib/isodoc/word_function/inline.rb +75 -0
  37. data/lib/isodoc/word_function/postprocess.rb +1 -0
  38. data/lib/isodoc/word_function/table.rb +3 -3
  39. data/lib/isodoc/xref.rb +59 -0
  40. data/lib/isodoc/{function → xref}/xref_anchor.rb +10 -21
  41. data/lib/isodoc/xref/xref_counter.rb +74 -0
  42. data/lib/isodoc/{function → xref}/xref_gen.rb +11 -23
  43. data/lib/isodoc/{function → xref}/xref_gen_seq.rb +41 -32
  44. data/lib/isodoc/{function → xref}/xref_sect_gen.rb +54 -40
  45. data/lib/isodoc/xslfo_convert.rb +21 -4
  46. data/spec/assets/i18n.yaml +4 -1
  47. data/spec/assets/odf.emf +0 -0
  48. data/spec/assets/odf.svg +4 -0
  49. data/spec/assets/odf1.svg +4 -0
  50. data/spec/isodoc/blocks_spec.rb +271 -48
  51. data/spec/isodoc/cleanup_spec.rb +139 -17
  52. data/spec/isodoc/footnotes_spec.rb +20 -5
  53. data/spec/isodoc/i18n_spec.rb +8 -8
  54. data/spec/isodoc/inline_spec.rb +299 -4
  55. data/spec/isodoc/lists_spec.rb +8 -8
  56. data/spec/isodoc/metadata_spec.rb +110 -3
  57. data/spec/isodoc/postproc_spec.rb +10 -14
  58. data/spec/isodoc/presentation_xml_spec.rb +20 -0
  59. data/spec/isodoc/ref_spec.rb +121 -52
  60. data/spec/isodoc/section_spec.rb +232 -208
  61. data/spec/isodoc/table_spec.rb +28 -28
  62. data/spec/isodoc/terms_spec.rb +7 -7
  63. data/spec/isodoc/xref_spec.rb +206 -59
  64. metadata +24 -17
  65. data/lib/isodoc/function/blocks_example.rb +0 -53
  66. data/lib/isodoc/function/xref_counter.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0256be2230e0c8757987eb82dee6f8ced68e1cc8794964fabbc446e78d53195
4
- data.tar.gz: a8bc10c2952aacf1542b3a4a1edae6c363bee78604dea3c541f9fd769031ea13
3
+ metadata.gz: 5b5e9597107793ecac111d5706640c399dcdec0411fdf49489c7058cf342bac2
4
+ data.tar.gz: 0b488bc57ff9c36a418f0012a49d68111a2e5f519a0a5d6191d201db99356526
5
5
  SHA512:
6
- metadata.gz: b54f7daa32cc4e7e80a560dfd660f76bf4acae581cda2c3b7f89012ab368da2d0951dec308982bea80e07b1e9d59eed1d170aecae686f42b82f31843a9fff4e9
7
- data.tar.gz: 75bceea7c655e1bf34de59ed6eb185596966c70b09f4da3c786c80fb57394a8e28c7f87cd47b1a795bee0b5e72d08f372981c587f27e3fb31240a96668cebeaf
6
+ metadata.gz: 26660b7ac5d08b63f0846c5d8a3caea1f58eed0491c1fcfe83ee3d3b9b3d73da9eaf57636fc48ed84370f12a1dd25e6043b5372750b03d6fc20547be0c6f22f0
7
+ data.tar.gz: 99fe284cd22c1c19dc3f4528ae057857194b0354f55cf31414b1dbc1d54f9c564b1b45101faaad426c69fb2fb15dd3ae2186d0532a95a1675f5b92f7658d7546
@@ -1,20 +1,26 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: macos
4
2
 
5
3
  on:
6
4
  push:
7
5
  branches: [ master ]
8
6
  pull_request:
7
+ paths-ignore:
8
+ - .github/workflows/ubuntu.yml
9
+ - .github/workflows/windows.yml
9
10
 
10
11
  jobs:
11
12
  test-macos:
12
13
  name: Test on Ruby ${{ matrix.ruby }} macOS
13
14
  runs-on: macos-latest
15
+ continue-on-error: ${{ matrix.experimental }}
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby: [ '2.6', '2.5', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
18
24
  steps:
19
25
  - uses: actions/checkout@master
20
26
  - name: Use Ruby
@@ -33,6 +39,10 @@ jobs:
33
39
  - name: Install Puppeteer
34
40
  run: |
35
41
  npm install -g puppeteer@3.0.1
42
+ - name: Install Inkscape
43
+ run: |
44
+ brew cask install inkscape
45
+ inkscape --version
36
46
  - name: Run specs
37
47
  run: |
38
48
  bundle exec rake
@@ -1,20 +1,26 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: ubuntu
4
2
 
5
3
  on:
6
4
  push:
7
5
  branches: [ master ]
8
6
  pull_request:
7
+ paths-ignore:
8
+ - .github/workflows/macos.yml
9
+ - .github/workflows/windows.yml
9
10
 
10
11
  jobs:
11
12
  test-linux:
12
13
  name: Test on Ruby ${{ matrix.ruby }} Ubuntu
13
14
  runs-on: ubuntu-latest
15
+ continue-on-error: ${{ matrix.experimental }}
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby: [ '2.6', '2.5', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
18
24
  steps:
19
25
  - uses: actions/checkout@master
20
26
  - name: Use Ruby
@@ -35,11 +41,17 @@ jobs:
35
41
  sudo apt-get update
36
42
  sudo apt-get install libgbm1
37
43
  npm install -g puppeteer@3.0.1
44
+ - name: Install Inkscape
45
+ run: |
46
+ sudo add-apt-repository ppa:inkscape.dev/stable
47
+ sudo apt update
48
+ sudo apt install inkscape
49
+ inkscape --version
38
50
  - name: Run specs
39
51
  run: |
40
52
  bundle exec rake
41
53
  - name: Trigger dependent repositories
42
- if: github.ref == 'refs/heads/master'
54
+ if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
43
55
  env:
44
56
  GH_USERNAME: ${{ secrets.PAT_USERNAME }}
45
57
  GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
@@ -1,20 +1,26 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: windows
4
2
 
5
3
  on:
6
4
  push:
7
5
  branches: [ master ]
8
6
  pull_request:
7
+ paths-ignore:
8
+ - .github/workflows/macos.yml
9
+ - .github/workflows/ubuntu.yml
9
10
 
10
11
  jobs:
11
12
  test-windows:
12
13
  name: Test on Ruby ${{ matrix.ruby }} Windows
13
14
  runs-on: windows-latest
15
+ continue-on-error: ${{ matrix.experimental }}
14
16
  strategy:
15
17
  fail-fast: false
16
18
  matrix:
17
19
  ruby: [ '2.6', '2.5', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
18
24
  steps:
19
25
  - uses: actions/checkout@master
20
26
  - name: Use Ruby
@@ -35,6 +41,10 @@ jobs:
35
41
  - name: Install Puppeteer
36
42
  run: |
37
43
  npm install -g puppeteer@3.0.1
44
+ - name: Install Inkscape
45
+ run: |
46
+ choco install --no-progress -y inkscape
47
+ inkscape --version
38
48
  - name: Run specs
39
49
  run: |
40
50
  bundle exec rake
@@ -36,8 +36,8 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "html2doc", "~> 1.0.0"
37
37
  spec.add_dependency "liquid"
38
38
  spec.add_dependency "roman-numerals"
39
- spec.add_dependency "sassc", "~> 2.2.1"
40
- spec.add_dependency "metanorma", "~> 1.0.0"
39
+ spec.add_dependency "sassc", "~> 2.4.0"
40
+ spec.add_dependency "metanorma", "~> 1.1.0"
41
41
  spec.add_dependency "rake", "~> 12.0"
42
42
 
43
43
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -21,6 +21,8 @@ require "isodoc/word_convert"
21
21
  require "isodoc/pdf_convert"
22
22
  require "isodoc/xslfo_convert"
23
23
  require "isodoc/headlesshtml_convert"
24
+ require "isodoc/presentation_xml_convert"
25
+ require "isodoc/xref"
24
26
 
25
27
  module IsoDoc
26
28
 
@@ -9,8 +9,6 @@ require_relative "./function/table"
9
9
  require_relative "./function/terms"
10
10
  require_relative "./function/to_word_html"
11
11
  require_relative "./function/utils"
12
- require_relative "./function/xref_gen"
13
- require_relative "./function/xref_sect_gen"
14
12
  require_relative "./function/reqt"
15
13
  require_relative "./class_utils"
16
14
 
@@ -27,8 +25,6 @@ module IsoDoc
27
25
  include Function::Terms
28
26
  include Function::ToWordHtml
29
27
  include Function::Utils
30
- include Function::XrefGen
31
- include Function::XrefSectGen
32
28
 
33
29
  extend ::IsoDoc::ClassUtils
34
30
  end
@@ -53,7 +53,6 @@ module IsoDoc
53
53
  @termexample = false
54
54
  @note = false
55
55
  @sourcecode = false
56
- @anchors = {}
57
56
  @footnotes = []
58
57
  @comments = []
59
58
  @in_footnote = false
@@ -142,7 +141,7 @@ module IsoDoc
142
141
  end
143
142
 
144
143
  def convert1(docxml, filename, dir)
145
- anchor_names docxml
144
+ @xrefs.parse docxml
146
145
  noko do |xml|
147
146
  xml.html **{ lang: "#{@lang}" } do |html|
148
147
  html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
@@ -158,25 +157,36 @@ module IsoDoc
158
157
  @meta = Metadata.new(lang, script, labels)
159
158
  end
160
159
 
161
- def convert_init(file, filename, debug)
160
+ def xref_init(lang, script, klass, labels, options)
161
+ @xrefs = Xref.new(lang, script, klass, labels, options)
162
+ end
163
+
164
+ def convert_init(file, input_filename, debug)
162
165
  docxml = Nokogiri::XML(file)
163
- filename, dir = init_file(filename, debug)
166
+ filename, dir = init_file(input_filename, debug)
164
167
  docxml.root.default_namespace = ""
165
168
  lang = docxml&.at(ns("//bibdata/language"))&.text || @lang
166
169
  script = docxml&.at(ns("//bibdata/script"))&.text || @script
167
170
  i18n_init(lang, script)
168
171
  metadata_init(lang, script, @labels)
172
+ xref_init(lang, script, self, @labels, {})
169
173
  [docxml, filename, dir]
170
174
  end
171
175
 
172
- def convert(filename, file = nil, debug = false)
173
- file = File.read(filename, encoding: "utf-8") if file.nil?
176
+ def convert(input_filename, file = nil, debug = false, output_filename = nil)
177
+ file = File.read(input_filename, encoding: "utf-8") if file.nil?
174
178
  @openmathdelim, @closemathdelim = extract_delims(file)
175
- docxml, filename, dir = convert_init(file, filename, debug)
179
+ docxml, filename, dir = convert_init(file, input_filename, debug)
176
180
  result = convert1(docxml, filename, dir)
177
181
  return result if debug
178
- postprocess(result, filename, dir)
182
+ output_filename ||= "#{filename}.#{@suffix}"
183
+ postprocess(result, output_filename, dir)
179
184
  FileUtils.rm_rf dir
180
185
  end
186
+
187
+ def middle_clause
188
+ "//clause[parent::sections][not(xmlns:title = 'Scope')]"\
189
+ "[not(descendant::terms)]".freeze
190
+ end
181
191
  end
182
192
  end
@@ -1,48 +1,12 @@
1
- require_relative "blocks_example"
1
+ require_relative "blocks_example_note"
2
2
 
3
3
  module IsoDoc::Function
4
4
  module Blocks
5
5
  @annotation = false
6
6
 
7
- def note_label(node)
8
- n = get_anchors[node["id"]]
9
- return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
10
- l10n("#{@note_lbl} #{n[:label]}")
11
- end
12
-
13
- def note_p_parse(node, div)
14
- div.p do |p|
15
- p.span **{ class: "note_label" } do |s|
16
- s << note_label(node)
17
- end
18
- insert_tab(p, 1)
19
- node.first_element_child.children.each { |n| parse(n, p) }
20
- end
21
- node.element_children[1..-1].each { |n| parse(n, div) }
22
- end
23
-
24
- def note_parse1(node, div)
25
- div.p do |p|
26
- p.span **{ class: "note_label" } do |s|
27
- s << note_label(node)
28
- end
29
- insert_tab(p, 1)
30
- end
31
- node.children.each { |n| parse(n, div) }
32
- end
33
-
34
- def note_parse(node, out)
35
- @note = true
36
- out.div **{ id: node["id"], class: "Note" } do |div|
37
- node.first_element_child.name == "p" ?
38
- note_p_parse(node, div) : note_parse1(node, div)
39
- end
40
- @note = false
41
- end
42
-
43
7
  def figure_name_parse(node, div, name)
44
8
  return if name.nil? && node.at(ns("./figure"))
45
- lbl = anchor(node['id'], :label, false)
9
+ lbl = @xrefs.anchor(node['id'], :label, false)
46
10
  lbl = nil if labelled_ancestor(node) && node.ancestors("figure").empty?
47
11
  return if lbl.nil? && name.nil?
48
12
  div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
@@ -58,11 +22,15 @@ module IsoDoc::Function
58
22
  end
59
23
  end
60
24
 
25
+ def figure_attrs(node)
26
+ attr_code(id: node["id"], class: "figure", style: keep_style(node))
27
+ end
28
+
61
29
  def figure_parse(node, out)
62
30
  return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
63
31
  node["type"] == "pseudocode"
64
32
  @in_figure = true
65
- out.div **attr_code(id: node["id"], class: "figure") do |div|
33
+ out.div **figure_attrs(node) do |div|
66
34
  node.children.each do |n|
67
35
  figure_key(out) if n.name == "dl"
68
36
  parse(n, div) unless n.name == "name"
@@ -72,10 +40,14 @@ module IsoDoc::Function
72
40
  @in_figure = false
73
41
  end
74
42
 
43
+ def pseudocode_attrs(node)
44
+ attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
45
+ end
46
+
75
47
  def pseudocode_parse(node, out)
76
48
  @in_figure = true
77
49
  name = node.at(ns("./name"))
78
- out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
50
+ out.div **pseudocode_attrs(node) do |div|
79
51
  node.children.each { |n| parse(n, div) unless n.name == "name" }
80
52
  sourcecode_name_parse(node, div, name)
81
53
  end
@@ -83,7 +55,7 @@ module IsoDoc::Function
83
55
  end
84
56
 
85
57
  def sourcecode_name_parse(node, div, name)
86
- lbl = anchor(node['id'], :label, false)
58
+ lbl = @xrefs.anchor(node['id'], :label, false)
87
59
  lbl = nil if labelled_ancestor(node)
88
60
  return if lbl.nil? && name.nil?
89
61
  div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
@@ -101,9 +73,13 @@ module IsoDoc::Function
101
73
  end
102
74
  end
103
75
 
76
+ def sourcecode_attrs(node)
77
+ attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
78
+ end
79
+
104
80
  def sourcecode_parse(node, out)
105
81
  name = node.at(ns("./name"))
106
- out.p **attr_code(id: node["id"], class: "Sourcecode") do |div|
82
+ out.p **sourcecode_attrs(node) do |div|
107
83
  @sourcecode = true
108
84
  node.children.each { |n| parse(n, div) unless n.name == "name" }
109
85
  @sourcecode = false
@@ -138,10 +114,15 @@ module IsoDoc::Function
138
114
  name
139
115
  end
140
116
 
117
+ def admonition_attrs(node)
118
+ attr_code(id: node["id"], class: admonition_class(node),
119
+ style: keep_style(node))
120
+ end
121
+
141
122
  def admonition_parse(node, out)
142
123
  type = node["type"]
143
124
  name = admonition_name(node, type)
144
- out.div **{ class: admonition_class(node) } do |t|
125
+ out.div **admonition_attrs(node) do |t|
145
126
  admonition_name_parse(node, t, name) if name
146
127
  node.children.each { |n| parse(n, t) unless n.name == "name" }
147
128
  end
@@ -157,10 +138,10 @@ module IsoDoc::Function
157
138
  end
158
139
 
159
140
  def formula_parse1(node, out)
160
- out.div **attr_code(id: node["id"], class: "formula") do |div|
141
+ out.div **attr_code(class: "formula") do |div|
161
142
  div.p do |p|
162
143
  parse(node.at(ns("./stem")), div)
163
- lbl = anchor(node['id'], :label, false)
144
+ lbl = @xrefs.anchor(node['id'], :label, false)
164
145
  unless lbl.nil?
165
146
  insert_tab(div, 1)
166
147
  div << "(#{lbl})"
@@ -169,12 +150,18 @@ module IsoDoc::Function
169
150
  end
170
151
  end
171
152
 
153
+ def formula_attrs(node)
154
+ attr_code(id: node["id"], style: keep_style(node))
155
+ end
156
+
172
157
  def formula_parse(node, out)
173
- formula_parse1(node, out)
174
- formula_where(node.at(ns("./dl")), out)
175
- node.children.each do |n|
176
- next if %w(stem dl).include? n.name
177
- parse(n, out)
158
+ out.div **formula_attrs(node) do |div|
159
+ formula_parse1(node, div)
160
+ formula_where(node.at(ns("./dl")), div)
161
+ node.children.each do |n|
162
+ next if %w(stem dl).include? n.name
163
+ parse(n, div)
164
+ end
178
165
  end
179
166
  end
180
167
 
@@ -187,8 +174,9 @@ module IsoDoc::Function
187
174
 
188
175
  def para_attrs(node)
189
176
  attrs = { class: para_class(node), id: node["id"] }
190
- node["align"].nil? or
191
- attrs[:style] = "text-align:#{node['align']};"
177
+ s = node["align"].nil? ? "" : "text-align:#{node['align']};"
178
+ s = "#{s}#{keep_style(node)}"
179
+ attrs[:style] = s unless s.empty?
192
180
  attrs
193
181
  end
194
182
 
@@ -222,5 +210,11 @@ module IsoDoc::Function
222
210
  quote_attribution(node, out)
223
211
  end
224
212
  end
213
+
214
+ def passthrough_parse(node, out)
215
+ return if node["format"] and
216
+ !(node["format"].split(/,/).include? @format.to_s)
217
+ out.passthrough node.text
218
+ end
225
219
  end
226
220
  end
@@ -0,0 +1,108 @@
1
+ module IsoDoc::Function
2
+ module Blocks
3
+ def example_label(node, div, name)
4
+ n = @xrefs.get[node["id"]]
5
+ div.p **{ class: "example-title" } do |p|
6
+ lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
7
+ l10n("#{@example_lbl} #{n[:label]}")
8
+ p << lbl
9
+ name and !lbl.nil? and p << "&nbsp;&mdash; "
10
+ name and name.children.each { |n| parse(n, div) }
11
+ end
12
+ end
13
+
14
+ EXAMPLE_TBL_ATTR =
15
+ { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
16
+ margin-left:0pt;vertical-align:top;" }.freeze
17
+
18
+ def example_div_attr(node)
19
+ attr_code(id: node["id"], class: "example", style: keep_style(node))
20
+ end
21
+
22
+ # used if we are boxing examples
23
+ def example_div_parse(node, out)
24
+ out.div **example_div_attr(node) do |div|
25
+ example_label(node, div, node.at(ns("./name")))
26
+ node.children.each do |n|
27
+ parse(n, div) unless n.name == "name"
28
+ end
29
+ end
30
+ end
31
+
32
+ def example_table_attr(node)
33
+ attr_code(id: node["id"], class: "example",
34
+ style: "border-collapse:collapse;border-spacing:0;"\
35
+ "#{keep_style(node)}" )
36
+ end
37
+
38
+ EXAMPLE_TD_ATTR =
39
+ { style: "vertical-align:top;padding:0;", class: "example" }.freeze
40
+
41
+ def example_table_parse(node, out)
42
+ out.table **example_table_attr(node) do |t|
43
+ t.tr do |tr|
44
+ tr.td **EXAMPLE_TBL_ATTR do |td|
45
+ example_label(node, td, node.at(ns("./name")))
46
+ end
47
+ tr.td **EXAMPLE_TD_ATTR do |td|
48
+ node.children.each { |n| parse(n, td) unless n.name == "name" }
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ def example_parse(node, out)
55
+ example_div_parse(node, out)
56
+ end
57
+
58
+ def note_label(node)
59
+ n = @xrefs.get[node["id"]]
60
+ return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
61
+ l10n("#{@note_lbl} #{n[:label]}")
62
+ end
63
+
64
+ def note_p_parse(node, div)
65
+ div.p do |p|
66
+ p.span **{ class: "note_label" } do |s|
67
+ s << note_label(node)
68
+ end
69
+ insert_tab(p, 1)
70
+ node.first_element_child.children.each { |n| parse(n, p) }
71
+ end
72
+ node.element_children[1..-1].each { |n| parse(n, div) }
73
+ end
74
+
75
+ def note_parse1(node, div)
76
+ div.p do |p|
77
+ p.span **{ class: "note_label" } do |s|
78
+ s << note_label(node)
79
+ end
80
+ insert_tab(p, 1)
81
+ end
82
+ node.children.each { |n| parse(n, div) }
83
+ end
84
+
85
+ def keep_style(node)
86
+ ret = ""
87
+ node["keep-with-next"] == "true" and
88
+ ret += "page-break-after: avoid;"
89
+ node["keep-lines-together"] == "true" and
90
+ ret += "page-break-inside: avoid;"
91
+ return nil if ret.empty?
92
+ ret
93
+ end
94
+
95
+ def note_attrs(node)
96
+ attr_code(id: node["id"], class: "Note", style: keep_style(node))
97
+ end
98
+
99
+ def note_parse(node, out)
100
+ @note = true
101
+ out.div **note_attrs(node) do |div|
102
+ node.first_element_child.name == "p" ?
103
+ note_p_parse(node, div) : note_parse1(node, div)
104
+ end
105
+ @note = false
106
+ end
107
+ end
108
+ end