isodoc 1.7.3 → 1.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +7 -4
  3. data/lib/isodoc/class_utils.rb +2 -2
  4. data/lib/isodoc/convert.rb +2 -0
  5. data/lib/isodoc/function/blocks_example_note.rb +85 -79
  6. data/lib/isodoc/function/cleanup.rb +181 -175
  7. data/lib/isodoc/function/inline.rb +110 -108
  8. data/lib/isodoc/function/inline_simple.rb +55 -55
  9. data/lib/isodoc/function/lists.rb +75 -71
  10. data/lib/isodoc/function/references.rb +165 -160
  11. data/lib/isodoc/function/section.rb +140 -190
  12. data/lib/isodoc/function/section_titles.rb +82 -0
  13. data/lib/isodoc/function/table.rb +90 -87
  14. data/lib/isodoc/function/terms.rb +58 -56
  15. data/lib/isodoc/function/to_word_html.rb +3 -1
  16. data/lib/isodoc/function/utils.rb +34 -14
  17. data/lib/isodoc/html_function/comments.rb +107 -111
  18. data/lib/isodoc/html_function/footnotes.rb +68 -67
  19. data/lib/isodoc/html_function/html.rb +113 -103
  20. data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
  21. data/lib/isodoc/presentation_function/block.rb +73 -78
  22. data/lib/isodoc/presentation_function/concept.rb +68 -0
  23. data/lib/isodoc/presentation_function/image.rb +112 -0
  24. data/lib/isodoc/presentation_function/inline.rb +6 -39
  25. data/lib/isodoc/presentation_function/math.rb +9 -0
  26. data/lib/isodoc/presentation_function/section.rb +12 -1
  27. data/lib/isodoc/presentation_xml_convert.rb +3 -0
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_function/body.rb +176 -174
  30. data/lib/isodoc/word_function/comments.rb +117 -112
  31. data/lib/isodoc/word_function/footnotes.rb +88 -86
  32. data/lib/isodoc/word_function/inline.rb +42 -67
  33. data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
  34. data/lib/isodoc/xref/xref_gen.rb +153 -150
  35. data/lib/isodoc/xslfo_convert.rb +2 -2
  36. data/lib/isodoc.rb +1 -1
  37. data/spec/assets/odf.svg +1 -4
  38. data/spec/isodoc/blocks_spec.rb +187 -32
  39. data/spec/isodoc/inline_spec.rb +300 -116
  40. data/spec/isodoc/postproc_spec.rb +38 -0
  41. data/spec/isodoc/presentation_xml_spec.rb +144 -0
  42. data/spec/isodoc/section_spec.rb +764 -0
  43. data/spec/isodoc/terms_spec.rb +116 -0
  44. metadata +63 -18
@@ -1,80 +1,80 @@
1
- module IsoDoc::Function
2
- module Inline
3
- def section_break(body)
4
- body.br
5
- end
1
+ module IsoDoc
2
+ module Function
3
+ module Inline
4
+ def section_break(body)
5
+ body.br
6
+ end
6
7
 
7
- def page_break(out)
8
- out.br
9
- end
8
+ def page_break(out)
9
+ out.br
10
+ end
10
11
 
11
- def pagebreak_parse(_node, out)
12
- out.br
13
- end
12
+ def pagebreak_parse(_node, out)
13
+ out.br
14
+ end
14
15
 
15
- def hr_parse(node, out)
16
- out.hr
17
- end
16
+ def hr_parse(_node, out)
17
+ out.hr
18
+ end
18
19
 
19
- def br_parse(node, out)
20
- out.br
21
- end
20
+ def br_parse(_node, out)
21
+ out.br
22
+ end
22
23
 
23
- def index_parse(node, out)
24
- end
24
+ def index_parse(node, out); end
25
25
 
26
- def index_xref_parse(node, out)
27
- end
26
+ def index_xref_parse(node, out); end
28
27
 
29
- def bookmark_parse(node, out)
30
- out.a **attr_code(id: node["id"])
31
- end
28
+ def bookmark_parse(node, out)
29
+ out.a **attr_code(id: node["id"])
30
+ end
32
31
 
33
- def keyword_parse(node, out)
34
- out.span **{ class: "keyword" } do |s|
35
- node.children.each { |n| parse(n, s) }
32
+ def keyword_parse(node, out)
33
+ out.span **{ class: "keyword" } do |s|
34
+ node.children.each { |n| parse(n, s) }
35
+ end
36
36
  end
37
- end
38
37
 
39
- def em_parse(node, out)
40
- out.i do |e|
41
- node.children.each { |n| parse(n, e) }
38
+ def em_parse(node, out)
39
+ out.i do |e|
40
+ node.children.each { |n| parse(n, e) }
41
+ end
42
42
  end
43
- end
44
43
 
45
- def strong_parse(node, out)
46
- out.b do |e|
47
- node.children.each { |n| parse(n, e) }
44
+ def strong_parse(node, out)
45
+ out.b do |e|
46
+ node.children.each { |n| parse(n, e) }
47
+ end
48
48
  end
49
- end
50
49
 
51
- def sup_parse(node, out)
52
- out.sup do |e|
53
- node.children.each { |n| parse(n, e) }
50
+ def sup_parse(node, out)
51
+ out.sup do |e|
52
+ node.children.each { |n| parse(n, e) }
53
+ end
54
54
  end
55
- end
56
55
 
57
- def sub_parse(node, out)
58
- out.sub do |e|
59
- node.children.each { |n| parse(n, e) }
56
+ def sub_parse(node, out)
57
+ out.sub do |e|
58
+ node.children.each { |n| parse(n, e) }
59
+ end
60
60
  end
61
- end
62
61
 
63
- def tt_parse(node, out)
64
- out.tt do |e|
65
- node.children.each { |n| parse(n, e) }
62
+ def tt_parse(node, out)
63
+ out.tt do |e|
64
+ node.children.each { |n| parse(n, e) }
65
+ end
66
66
  end
67
- end
68
67
 
69
- def strike_parse(node, out)
70
- out.s do |e|
71
- node.children.each { |n| parse(n, e) }
68
+ def strike_parse(node, out)
69
+ out.s do |e|
70
+ node.children.each { |n| parse(n, e) }
71
+ end
72
72
  end
73
- end
74
73
 
75
- def underline_parse(node, out)
76
- out.u do |e|
77
- node.children.each { |n| parse(n, e) }
74
+ def underline_parse(node, out)
75
+ out.u do |e|
76
+ node.children.each { |n| parse(n, e) }
77
+ end
78
78
  end
79
79
  end
80
80
  end
@@ -1,95 +1,99 @@
1
- module IsoDoc::Function
2
- module Lists
3
- def ul_attrs(node)
4
- { id: node["id"], style: keep_style(node) }
5
- end
1
+ module IsoDoc
2
+ module Function
3
+ module Lists
4
+ def ul_attrs(node)
5
+ { id: node["id"], style: keep_style(node) }
6
+ end
6
7
 
7
- def ul_parse(node, out)
8
- out.ul **attr_code(ul_attrs(node)) do |ul|
9
- node.children.each { |n| parse(n, ul) }
8
+ def ul_parse(node, out)
9
+ out.ul **attr_code(ul_attrs(node)) do |ul|
10
+ node.children.each { |n| parse(n, ul) }
11
+ end
10
12
  end
11
- end
12
13
 
13
- OL_STYLE = {
14
- arabic: "1",
15
- roman: "i",
16
- alphabet: "a",
17
- roman_upper: "I",
18
- alphabet_upper: "A",
19
- }.freeze
14
+ OL_STYLE = {
15
+ arabic: "1",
16
+ roman: "i",
17
+ alphabet: "a",
18
+ roman_upper: "I",
19
+ alphabet_upper: "A",
20
+ }.freeze
20
21
 
21
- def ol_style(type)
22
- type = :alphabet unless type
23
- OL_STYLE[type.to_sym]
24
- end
22
+ def ol_style(type)
23
+ type ||= :alphabet
24
+ OL_STYLE[type.to_sym]
25
+ end
25
26
 
26
- # We don't really want users to specify type of ordered list;
27
- # we will use a fixed hierarchy as practiced by ISO (though not
28
- # fully spelled out): a) 1) i) A) I)
27
+ # We don't really want users to specify type of ordered list;
28
+ # we will use a fixed hierarchy as practiced by ISO (though not
29
+ # fully spelled out): a) 1) i) A) I)
29
30
 
30
- def ol_depth(node)
31
- depth = node.ancestors("ul, ol").size + 1
32
- type = :alphabet
33
- type = :arabic if [2, 7].include? depth
34
- type = :roman if [3, 8].include? depth
35
- type = :alphabet_upper if [4, 9].include? depth
36
- type = :roman_upper if [5, 10].include? depth
37
- ol_style(type)
38
- end
31
+ def ol_depth(node)
32
+ depth = node.ancestors("ul, ol").size + 1
33
+ type = :alphabet
34
+ type = :arabic if [2, 7].include? depth
35
+ type = :roman if [3, 8].include? depth
36
+ type = :alphabet_upper if [4, 9].include? depth
37
+ type = :roman_upper if [5, 10].include? depth
38
+ ol_style(type)
39
+ end
39
40
 
40
- def ol_attrs(node)
41
- { type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
42
- id: node["id"], style: keep_style(node) }
43
- end
41
+ def ol_attrs(node)
42
+ { type: node["type"] ? ol_style(node["type"].to_sym) : ol_depth(node),
43
+ id: node["id"], style: keep_style(node) }
44
+ end
44
45
 
45
- def ol_parse(node, out)
46
- out.ol **attr_code(ol_attrs(node)) do |ol|
47
- node.children.each { |n| parse(n, ol) }
46
+ def ol_parse(node, out)
47
+ out.ol **attr_code(ol_attrs(node)) do |ol|
48
+ node.children.each { |n| parse(n, ol) }
49
+ end
48
50
  end
49
- end
50
51
 
51
- def li_parse(node, out)
52
- out.li **attr_code(id: node["id"]) do |li|
53
- if node["uncheckedcheckbox"] == "true"
54
- li << '<span class="zzMoveToFollowing"><input type="checkbox" checked="checked"/></span>'
55
- elsif node["checkedcheckbox"] == "true"
56
- li << '<span class="zzMoveToFollowing"><input type="checkbox"/></span>'
52
+ def li_parse(node, out)
53
+ out.li **attr_code(id: node["id"]) do |li|
54
+ if node["uncheckedcheckbox"] == "true"
55
+ li << '<span class="zzMoveToFollowing">'\
56
+ '<input type="checkbox" checked="checked"/></span>'
57
+ elsif node["checkedcheckbox"] == "true"
58
+ li << '<span class="zzMoveToFollowing">'\
59
+ '<input type="checkbox"/></span>'
60
+ end
61
+ node.children.each { |n| parse(n, li) }
57
62
  end
58
- node.children.each { |n| parse(n, li) }
59
63
  end
60
- end
61
64
 
62
- def dt_parse(dt, term)
63
- if dt.elements.empty?
64
- #term.p **attr_code(class: note? ? "Note" : nil) do |p|
65
- term.p do |p|
66
- p << dt.text
65
+ def dt_parse(dterm, term)
66
+ if dterm.elements.empty?
67
+ # term.p **attr_code(class: note? ? "Note" : nil) do |p|
68
+ term.p do |p|
69
+ p << dterm.text
70
+ end
71
+ else
72
+ dterm.children.each { |n| parse(n, term) }
67
73
  end
68
- else
69
- dt.children.each { |n| parse(n, term) }
70
74
  end
71
- end
72
75
 
73
- def dt_dd?(n)
74
- %w{dt dd}.include? n.name
75
- end
76
+ def dt_dd?(node)
77
+ %w{dt dd}.include? node.name
78
+ end
76
79
 
77
- def dl_attrs(node)
78
- attr_code(id: node["id"], style: keep_style(node))
79
- end
80
+ def dl_attrs(node)
81
+ attr_code(id: node["id"], style: keep_style(node))
82
+ end
80
83
 
81
- def dl_parse(node, out)
82
- out.dl **dl_attrs(node) do |v|
83
- node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
84
- v.dt **attr_code(id: dt["id"]) do |term|
85
- dt_parse(dt, term)
86
- end
87
- v.dd **attr_code(id: dd["id"]) do |listitem|
88
- dd.children.each { |n| parse(n, listitem) }
84
+ def dl_parse(node, out)
85
+ out.dl **dl_attrs(node) do |v|
86
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
87
+ v.dt **attr_code(id: dt["id"]) do |term|
88
+ dt_parse(dt, term)
89
+ end
90
+ v.dd **attr_code(id: dd["id"]) do |listitem|
91
+ dd.children.each { |n| parse(n, listitem) }
92
+ end
89
93
  end
90
94
  end
95
+ node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
91
96
  end
92
- node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
93
97
  end
94
98
  end
95
99
  end