isodoc 1.7.3.1 → 1.7.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +7 -4
- data/lib/isodoc/class_utils.rb +2 -2
- data/lib/isodoc/convert.rb +2 -0
- data/lib/isodoc/function/blocks_example_note.rb +85 -79
- data/lib/isodoc/function/cleanup.rb +181 -175
- data/lib/isodoc/function/inline.rb +110 -108
- data/lib/isodoc/function/inline_simple.rb +55 -55
- data/lib/isodoc/function/lists.rb +75 -71
- data/lib/isodoc/function/references.rb +165 -160
- data/lib/isodoc/function/section.rb +140 -190
- data/lib/isodoc/function/section_titles.rb +82 -0
- data/lib/isodoc/function/table.rb +90 -87
- data/lib/isodoc/function/terms.rb +58 -56
- data/lib/isodoc/function/to_word_html.rb +3 -1
- data/lib/isodoc/function/utils.rb +34 -14
- data/lib/isodoc/html_function/comments.rb +107 -111
- data/lib/isodoc/html_function/footnotes.rb +68 -67
- data/lib/isodoc/html_function/html.rb +113 -103
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
- data/lib/isodoc/presentation_function/block.rb +73 -78
- data/lib/isodoc/presentation_function/concept.rb +68 -0
- data/lib/isodoc/presentation_function/image.rb +112 -0
- data/lib/isodoc/presentation_function/inline.rb +6 -39
- data/lib/isodoc/presentation_function/math.rb +9 -0
- data/lib/isodoc/presentation_function/section.rb +12 -1
- data/lib/isodoc/presentation_xml_convert.rb +3 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +176 -174
- data/lib/isodoc/word_function/comments.rb +117 -112
- data/lib/isodoc/word_function/footnotes.rb +88 -86
- data/lib/isodoc/word_function/inline.rb +42 -67
- data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
- data/lib/isodoc/xref/xref_gen.rb +153 -150
- data/lib/isodoc/xslfo_convert.rb +2 -2
- data/spec/assets/odf.svg +1 -4
- data/spec/isodoc/blocks_spec.rb +187 -32
- data/spec/isodoc/inline_spec.rb +300 -116
- data/spec/isodoc/postproc_spec.rb +38 -0
- data/spec/isodoc/presentation_xml_spec.rb +144 -0
- data/spec/isodoc/section_spec.rb +764 -0
- data/spec/isodoc/terms_spec.rb +116 -0
- metadata +63 -18
@@ -1,80 +1,80 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module
|
3
|
-
|
4
|
-
body
|
5
|
-
|
1
|
+
module IsoDoc
|
2
|
+
module Function
|
3
|
+
module Inline
|
4
|
+
def section_break(body)
|
5
|
+
body.br
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def page_break(out)
|
9
|
+
out.br
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def pagebreak_parse(_node, out)
|
13
|
+
out.br
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def hr_parse(_node, out)
|
17
|
+
out.hr
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def br_parse(_node, out)
|
21
|
+
out.br
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
end
|
24
|
+
def index_parse(node, out); end
|
25
25
|
|
26
|
-
|
27
|
-
end
|
26
|
+
def index_xref_parse(node, out); end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def bookmark_parse(node, out)
|
29
|
+
out.a **attr_code(id: node["id"])
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
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
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def ol_style(type)
|
23
|
+
type ||= :alphabet
|
24
|
+
OL_STYLE[type.to_sym]
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
+
def dt_dd?(node)
|
77
|
+
%w{dt dd}.include? node.name
|
78
|
+
end
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
def dl_attrs(node)
|
81
|
+
attr_code(id: node["id"], style: keep_style(node))
|
82
|
+
end
|
80
83
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|