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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 411fdbd359b728afea9bcab7225c1e79a2a2698dd37c6219c70a1434cfa09286
|
4
|
+
data.tar.gz: 05a4997c47971d8cc74985ea8a0cf7b4e2c0d0e15a144e68eae007ce24176c9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7db1599bdd9d90aada565fbb02d4744a1ac85de0798c2dfd33d2b76905e5f40894042df0e0131a282fa669509f590cf471285188f6dd8e3c091d3bf6c0809bb3
|
7
|
+
data.tar.gz: cd90f9f57aa3ccd37d59d7ebc14438dd37c8812e3d131d7d82618499bfd69c25f660716a508621f536e72a68b942571347fb7218a746c42e61296e4e7fef3da8
|
data/isodoc.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ["open.source@ribose.com"]
|
12
12
|
|
13
13
|
spec.summary = "Convert documents in IsoDoc into Word and HTML "\
|
14
|
-
|
14
|
+
"in AsciiDoc."
|
15
15
|
spec.description = <<~DESCRIPTION
|
16
16
|
isodoc converts documents in the IsoDoc document model into
|
17
17
|
Microsoft Word and HTML.
|
@@ -32,8 +32,11 @@ 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"
|
36
|
-
spec.add_dependency "
|
35
|
+
# spec.add_dependency "metanorma", ">= 1.2.0"
|
36
|
+
spec.add_dependency "emf2svg", "~> 1"
|
37
|
+
spec.add_dependency "mathml2asciimath"
|
38
|
+
spec.add_dependency "metanorma-utils"
|
39
|
+
spec.add_dependency "nokogiri", "~> 1.12.0"
|
37
40
|
spec.add_dependency "relaton-cli"
|
38
41
|
spec.add_dependency "roman-numerals"
|
39
42
|
spec.add_dependency "thread_safe"
|
@@ -44,12 +47,12 @@ Gem::Specification.new do |spec|
|
|
44
47
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
45
48
|
spec.add_development_dependency "guard", "~> 2.14"
|
46
49
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
50
|
+
spec.add_development_dependency "metanorma-iso"
|
47
51
|
spec.add_development_dependency "rake", "~> 13.0"
|
48
52
|
spec.add_development_dependency "rexml"
|
49
53
|
spec.add_development_dependency "rspec", "~> 3.6"
|
50
54
|
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
51
55
|
spec.add_development_dependency "sassc", "~> 2.4.0"
|
52
56
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
53
|
-
spec.add_development_dependency "metanorma-iso"
|
54
57
|
spec.add_development_dependency "timecop", "~> 0.9"
|
55
58
|
end
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -23,8 +23,8 @@ module IsoDoc
|
|
23
23
|
# unescape HTML escapes in doc
|
24
24
|
doc = doc.split(%r<(\{%|%\})>).each_slice(4).map do |a|
|
25
25
|
a[2] = a[2].gsub("<", "<").gsub(">", ">") if a.size > 2
|
26
|
-
a.join
|
27
|
-
end.join
|
26
|
+
a.join
|
27
|
+
end.join
|
28
28
|
Liquid::Template.parse(doc)
|
29
29
|
end
|
30
30
|
end
|
data/lib/isodoc/convert.rb
CHANGED
@@ -75,6 +75,7 @@ module IsoDoc
|
|
75
75
|
@suppressheadingnumbers = options[:suppressheadingnumbers]
|
76
76
|
@break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
|
77
77
|
@sectionsplit = options[:sectionsplit] == "true"
|
78
|
+
@suppressasciimathdup = options[:suppressasciimathdup] == "true"
|
78
79
|
@bare = options[:bare]
|
79
80
|
@termdomain = ""
|
80
81
|
@termexample = false
|
@@ -100,6 +101,7 @@ module IsoDoc
|
|
100
101
|
@htmlToClevels = 2 if @htmlToClevels.zero?
|
101
102
|
@bookmarks_allocated = { "X" => true }
|
102
103
|
@fn_bookmarks = {}
|
104
|
+
@baseassetpath = options[:baseassetpath]
|
103
105
|
end
|
104
106
|
|
105
107
|
def tmpimagedir_suffix
|
@@ -1,107 +1,113 @@
|
|
1
|
-
module IsoDoc
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module IsoDoc
|
2
|
+
module Function
|
3
|
+
module Blocks
|
4
|
+
def example_label(_node, div, name)
|
5
|
+
return if name.nil?
|
6
|
+
|
7
|
+
div.p **{ class: "example-title" } do |_p|
|
8
|
+
name.children.each { |n| parse(n, div) }
|
9
|
+
end
|
7
10
|
end
|
8
|
-
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
EXAMPLE_TBL_ATTR =
|
13
|
+
{ class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
|
12
14
|
margin-left:0pt;vertical-align:top;" }.freeze
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
def example_div_attr(node)
|
17
|
+
attr_code(id: node["id"], class: "example", style: keep_style(node))
|
18
|
+
end
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
# used if we are boxing examples
|
21
|
+
def example_div_parse(node, out)
|
22
|
+
out.div **example_div_attr(node) do |div|
|
23
|
+
example_label(node, div, node.at(ns("./name")))
|
24
|
+
node.children.each do |n|
|
25
|
+
parse(n, div) unless n.name == "name"
|
26
|
+
end
|
24
27
|
end
|
25
28
|
end
|
26
|
-
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
def example_table_attr(node)
|
31
|
+
attr_code(id: node["id"], class: "example",
|
32
|
+
style: "border-collapse:collapse;border-spacing:0;"\
|
33
|
+
"#{keep_style(node)}")
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
EXAMPLE_TD_ATTR =
|
37
|
+
{ style: "vertical-align:top;padding:0;", class: "example" }.freeze
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
def example_table_parse(node, out)
|
40
|
+
out.table **example_table_attr(node) do |t|
|
41
|
+
t.tr do |tr|
|
42
|
+
tr.td **EXAMPLE_TBL_ATTR do |td|
|
43
|
+
example_label(node, td, node.at(ns("./name")))
|
44
|
+
end
|
45
|
+
tr.td **EXAMPLE_TD_ATTR do |td|
|
46
|
+
node.children.each { |n| parse(n, td) unless n.name == "name" }
|
47
|
+
end
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
48
|
-
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
def example_parse(node, out)
|
53
|
+
example_div_parse(node, out)
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
def note_delim
|
57
|
+
""
|
58
|
+
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
def note_p_parse(node, div)
|
61
|
+
name = node&.at(ns("./name"))&.remove
|
62
|
+
div.p do |p|
|
63
|
+
name and p.span **{ class: "note_label" } do |s|
|
64
|
+
name.children.each { |n| parse(n, s) }
|
65
|
+
s << note_delim
|
66
|
+
end
|
67
|
+
insert_tab(p, 1)
|
68
|
+
node.first_element_child.children.each { |n| parse(n, p) }
|
64
69
|
end
|
65
|
-
|
66
|
-
node.first_element_child.children.each { |n| parse(n, p) }
|
70
|
+
node.element_children[1..-1].each { |n| parse(n, div) }
|
67
71
|
end
|
68
|
-
node.element_children[1..-1].each { |n| parse(n, div) }
|
69
|
-
end
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
def note_parse1(node, div)
|
74
|
+
name = node&.at(ns("./name"))&.remove
|
75
|
+
name and div.p do |p|
|
76
|
+
p.span **{ class: "note_label" } do |s|
|
77
|
+
name.children.each { |n| parse(n, s) }
|
78
|
+
s << note_delim
|
79
|
+
end
|
80
|
+
insert_tab(p, 1)
|
77
81
|
end
|
78
|
-
|
82
|
+
node.children.each { |n| parse(n, div) }
|
79
83
|
end
|
80
|
-
node.children.each { |n| parse(n, div) }
|
81
|
-
end
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
ret
|
91
|
-
end
|
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
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
ret
|
94
|
+
end
|
95
|
+
|
96
|
+
def note_attrs(node)
|
97
|
+
attr_code(id: node["id"], class: "Note", style: keep_style(node))
|
98
|
+
end
|
96
99
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
100
|
+
def note_parse(node, out)
|
101
|
+
@note = true
|
102
|
+
out.div **note_attrs(node) do |div|
|
103
|
+
if node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p"
|
104
|
+
note_p_parse(node, div)
|
105
|
+
else
|
106
|
+
note_parse1(node, div)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
@note = false
|
103
110
|
end
|
104
|
-
@note = false
|
105
111
|
end
|
106
112
|
end
|
107
113
|
end
|