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.
Files changed (43) 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/spec/assets/odf.svg +1 -4
  37. data/spec/isodoc/blocks_spec.rb +187 -32
  38. data/spec/isodoc/inline_spec.rb +300 -116
  39. data/spec/isodoc/postproc_spec.rb +38 -0
  40. data/spec/isodoc/presentation_xml_spec.rb +144 -0
  41. data/spec/isodoc/section_spec.rb +764 -0
  42. data/spec/isodoc/terms_spec.rb +116 -0
  43. metadata +63 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4857e477eb5f0f04d2af2e0943ad584b0dba6677cbbd25ae8a0d7ab36bfc2058
4
- data.tar.gz: 8b9d5bc48cf81a15edbef1230996d22f0731e2071a5d726bc0621d48da09009c
3
+ metadata.gz: 411fdbd359b728afea9bcab7225c1e79a2a2698dd37c6219c70a1434cfa09286
4
+ data.tar.gz: 05a4997c47971d8cc74985ea8a0cf7b4e2c0d0e15a144e68eae007ce24176c9a
5
5
  SHA512:
6
- metadata.gz: e5d2ab8c7a03057d7e82b255fd1e2a5a4cf6ace0b074e4462cadeddfe1c509f45401808197f9d78edfed2912f4f283b40dfeaea8386cb32cb024d2994309d31d
7
- data.tar.gz: e0fe9adb6ede2c2a78c4fb69e8dd70343c48227b088346178fce3af699d187746cbddcc9c250d5cddd5cf4a0a543ba270733b0e7f4872877b38f9111a51894b7
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
- "in AsciiDoc."
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 "nokogiri", "~> 1.11.0"
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
@@ -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("&lt;", "<").gsub("&gt;", ">") 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
@@ -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::Function
2
- module Blocks
3
- def example_label(node, div, name)
4
- return if name.nil?
5
- div.p **{ class: "example-title" } do |p|
6
- name.children.each { |n| parse(n, div) }
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
- EXAMPLE_TBL_ATTR =
11
- { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
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
- def example_div_attr(node)
15
- attr_code(id: node["id"], class: "example", style: keep_style(node))
16
- end
16
+ def example_div_attr(node)
17
+ attr_code(id: node["id"], class: "example", style: keep_style(node))
18
+ end
17
19
 
18
- # used if we are boxing examples
19
- def example_div_parse(node, out)
20
- out.div **example_div_attr(node) do |div|
21
- example_label(node, div, node.at(ns("./name")))
22
- node.children.each do |n|
23
- parse(n, div) unless n.name == "name"
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
- def example_table_attr(node)
29
- attr_code(id: node["id"], class: "example",
30
- style: "border-collapse:collapse;border-spacing:0;"\
31
- "#{keep_style(node)}" )
32
- end
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
- EXAMPLE_TD_ATTR =
35
- { style: "vertical-align:top;padding:0;", class: "example" }.freeze
36
+ EXAMPLE_TD_ATTR =
37
+ { style: "vertical-align:top;padding:0;", class: "example" }.freeze
36
38
 
37
- def example_table_parse(node, out)
38
- out.table **example_table_attr(node) do |t|
39
- t.tr do |tr|
40
- tr.td **EXAMPLE_TBL_ATTR do |td|
41
- example_label(node, td, node.at(ns("./name")))
42
- end
43
- tr.td **EXAMPLE_TD_ATTR do |td|
44
- node.children.each { |n| parse(n, td) unless n.name == "name" }
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
- def example_parse(node, out)
51
- example_div_parse(node, out)
52
- end
52
+ def example_parse(node, out)
53
+ example_div_parse(node, out)
54
+ end
53
55
 
54
- def note_delim
55
- ""
56
- end
56
+ def note_delim
57
+ ""
58
+ end
57
59
 
58
- def note_p_parse(node, div)
59
- name = node&.at(ns("./name"))&.remove
60
- div.p do |p|
61
- name and p.span **{ class: "note_label" } do |s|
62
- name.children.each { |n| parse(n, s) }
63
- s << note_delim
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
- insert_tab(p, 1)
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
- def note_parse1(node, div)
72
- name = node&.at(ns("./name"))&.remove
73
- name and div.p do |p|
74
- p.span **{ class: "note_label" } do |s|
75
- name.children.each { |n| parse(n, s) }
76
- s << note_delim
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
- insert_tab(p, 1)
82
+ node.children.each { |n| parse(n, div) }
79
83
  end
80
- node.children.each { |n| parse(n, div) }
81
- end
82
84
 
83
- def keep_style(node)
84
- ret = ""
85
- node["keep-with-next"] == "true" and
86
- ret += "page-break-after: avoid;"
87
- node["keep-lines-together"] == "true" and
88
- ret += "page-break-inside: avoid;"
89
- return nil if ret.empty?
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
- def note_attrs(node)
94
- attr_code(id: node["id"], class: "Note", style: keep_style(node))
95
- end
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
- def note_parse(node, out)
98
- @note = true
99
- out.div **note_attrs(node) do |div|
100
- node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p" ?
101
- # node.first_element_child.name == "p" ?
102
- note_p_parse(node, div) : note_parse1(node, div)
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