isodoc 1.2.7 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +14 -9
  3. data/README.adoc +1 -3
  4. data/isodoc.gemspec +1 -1
  5. data/lib/isodoc-yaml/i18n-en.yaml +56 -0
  6. data/lib/isodoc-yaml/i18n-fr.yaml +64 -7
  7. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  8. data/lib/isodoc/base_style/blocks.scss +2 -2
  9. data/lib/isodoc/base_style/typography.scss +1 -1
  10. data/lib/isodoc/convert.rb +13 -85
  11. data/lib/isodoc/css.rb +95 -0
  12. data/lib/isodoc/function/inline.rb +0 -33
  13. data/lib/isodoc/function/inline_simple.rb +10 -1
  14. data/lib/isodoc/function/lists.rb +2 -1
  15. data/lib/isodoc/function/references.rb +8 -13
  16. data/lib/isodoc/function/section.rb +1 -1
  17. data/lib/isodoc/function/table.rb +10 -0
  18. data/lib/isodoc/function/to_word_html.rb +2 -2
  19. data/lib/isodoc/gem_tasks.rb +4 -0
  20. data/lib/isodoc/html_function/html.rb +7 -0
  21. data/lib/isodoc/html_function/mathvariant_to_plain.rb +82 -0
  22. data/lib/isodoc/html_function/postprocess.rb +41 -20
  23. data/lib/isodoc/i18n.rb +15 -2
  24. data/lib/isodoc/metadata_contributor.rb +4 -3
  25. data/lib/isodoc/presentation_function/bibdata.rb +3 -3
  26. data/lib/isodoc/presentation_function/block.rb +14 -9
  27. data/lib/isodoc/presentation_function/inline.rb +126 -22
  28. data/lib/isodoc/presentation_function/section.rb +9 -0
  29. data/lib/isodoc/presentation_xml_convert.rb +5 -0
  30. data/lib/isodoc/version.rb +1 -1
  31. data/lib/isodoc/word_convert.rb +0 -20
  32. data/lib/isodoc/word_function/body.rb +12 -0
  33. data/lib/isodoc/word_function/postprocess.rb +38 -80
  34. data/lib/isodoc/word_function/postprocess_cover.rb +55 -0
  35. data/lib/isodoc/word_function/table.rb +10 -0
  36. data/lib/isodoc/xref.rb +1 -0
  37. data/lib/isodoc/xref/xref_counter.rb +20 -9
  38. data/lib/isodoc/xref/xref_gen.rb +20 -2
  39. data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
  40. data/spec/assets/html.scss +14 -0
  41. data/spec/assets/i18n.yaml +7 -6
  42. data/spec/isodoc/blocks_spec.rb +2 -1
  43. data/spec/isodoc/cleanup_spec.rb +0 -1
  44. data/spec/isodoc/footnotes_spec.rb +4 -5
  45. data/spec/isodoc/i18n_spec.rb +23 -2
  46. data/spec/isodoc/inline_spec.rb +182 -202
  47. data/spec/isodoc/lists_spec.rb +1 -1
  48. data/spec/isodoc/metadata_spec.rb +3 -1
  49. data/spec/isodoc/postproc_spec.rb +472 -11
  50. data/spec/isodoc/presentation_xml_spec.rb +584 -1
  51. data/spec/isodoc/ref_spec.rb +325 -7
  52. data/spec/isodoc/table_spec.rb +28 -0
  53. data/spec/isodoc/xref_spec.rb +162 -17
  54. metadata +18 -16
@@ -75,5 +75,60 @@ module IsoDoc::WordFunction
75
75
  toc.sub(/(<p class="MsoToc1">)/,
76
76
  %{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
77
77
  end
78
+
79
+ def authority_cleanup1(docxml, klass)
80
+ dest = docxml.at("//div[@id = 'boilerplate-#{klass}-destination']")
81
+ auth = docxml.at("//div[@id = 'boilerplate-#{klass}' or @class = 'boilerplate-#{klass}']")
82
+ auth&.xpath(".//h1[not(text())] | .//h2[not(text())]")&.each { |h| h.remove }
83
+ auth&.xpath(".//h1 | .//h2")&.each do |h|
84
+ h.name = "p"
85
+ h["class"] = "TitlePageSubhead"
86
+ end
87
+ dest and auth and dest.replace(auth.remove)
88
+ end
89
+
90
+ def authority_cleanup(docxml)
91
+ %w(copyright license legal feedback).each do |t|
92
+ authority_cleanup1(docxml, t)
93
+ end
94
+ end
95
+
96
+ def generate_header(filename, _dir)
97
+ return nil unless @header
98
+ template = IsoDoc::Common.liquid(File.read(@header, encoding: "UTF-8"))
99
+ meta = @meta.get.merge(@labels || {}).merge(@meta.labels || {})
100
+ meta[:filename] = filename
101
+ params = meta.map { |k, v| [k.to_s, v] }.to_h
102
+ Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
103
+ f.write(template.render(params))
104
+ f
105
+ end
106
+ end
107
+
108
+ def word_section_breaks(docxml)
109
+ @landscapestyle = ""
110
+ word_section_breaks1(docxml, "WordSection2")
111
+ word_section_breaks1(docxml, "WordSection3")
112
+ word_remove_pb_before_annex(docxml)
113
+ docxml.xpath("//br[@orientation]").each { |br| br.delete("orientation") }
114
+ end
115
+
116
+ def word_section_breaks1(docxml, sect)
117
+ docxml.xpath("//div[@class = '#{sect}']//br[@orientation]").reverse.
118
+ each_with_index do |br, i|
119
+ @landscapestyle += "\ndiv.#{sect}_#{i} {page:#{sect}#{br["orientation"] == "landscape" ? "L" : "P"};}\n"
120
+ split_at_section_break(docxml, sect, br, i)
121
+ end
122
+ end
123
+
124
+ def split_at_section_break(docxml, sect, br, i)
125
+ move = br.parent.xpath("following::node()") &
126
+ br.document.xpath("//div[@class = '#{sect}']//*")
127
+ ins = docxml.at("//div[@class = '#{sect}']").after("<div class='#{sect}_#{i}'/>").next_element
128
+ move.each do |m|
129
+ next if m.at("./ancestor::div[@class = '#{sect}_#{i}']")
130
+ ins << m.remove
131
+ end
132
+ end
78
133
  end
79
134
  end
@@ -43,11 +43,21 @@ module IsoDoc::WordFunction
43
43
  }))
44
44
  end
45
45
 
46
+ def colgroup(node, t)
47
+ colgroup = node.at(ns("./colgroup")) or return
48
+ t.colgroup do |cg|
49
+ colgroup.xpath(ns("./col")).each do |c|
50
+ cg.col **{ width: c["width"] }
51
+ end
52
+ end
53
+ end
54
+
46
55
  def table_parse(node, out)
47
56
  @in_table = true
48
57
  table_title_parse(node, out)
49
58
  out.div **{ align: "center", class: "table_container" } do |div|
50
59
  div.table **table_attrs(node) do |t|
60
+ colgroup(node, t)
51
61
  thead_parse(node, t)
52
62
  tbody_parse(node, t)
53
63
  tfoot_parse(node, t)
@@ -49,6 +49,7 @@ module IsoDoc
49
49
  note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
50
50
  example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
51
51
  list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
52
+ bookmark_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
52
53
  end
53
54
 
54
55
  def ns(xpath)
@@ -2,8 +2,8 @@ require "roman-numerals"
2
2
 
3
3
  module IsoDoc::XrefGen
4
4
  class Counter
5
- def initialize
6
- @num = 0
5
+ def initialize(num = 0)
6
+ @num = num
7
7
  @letter = ""
8
8
  @subseq = ""
9
9
  @letter_override = nil
@@ -76,13 +76,24 @@ module IsoDoc::XrefGen
76
76
  "#{@base}#{@number_override || @num}#{@letter_override || @letter}"
77
77
  end
78
78
 
79
- def listlabel(depth)
80
- return @num.to_s if [2, 7].include? depth
81
- return (96 + @num).chr.to_s if [1, 6].include? depth
82
- return (64 + @num).chr.to_s if [4, 9].include? depth
83
- return RomanNumerals.to_roman(@num).downcase if [3, 8].include? depth
84
- return RomanNumerals.to_roman(@num).upcase if [5, 10].include? depth
85
- return @num.to_s
79
+ def ol_type(list, depth)
80
+ return list["type"].to_sym if list["type"]
81
+ return :arabic if [2, 7].include? depth
82
+ return :alphabet if [1, 6].include? depth
83
+ return :alphabet_upper if [4, 9].include? depth
84
+ return :roman if [3, 8].include? depth
85
+ return :roman_upper if [5, 10].include? depth
86
+ return :arabic
87
+ end
88
+
89
+ def listlabel(list, depth)
90
+ case ol_type(list, depth)
91
+ when :arabic then @num.to_s
92
+ when :alphabet then (96 + @num).chr.to_s
93
+ when :alphabet_upper then (64 + @num).chr.to_s
94
+ when :roman then RomanNumerals.to_roman(@num).downcase
95
+ when :roman_upper then RomanNumerals.to_roman(@num).upcase
96
+ end
86
97
  end
87
98
  end
88
99
  end
@@ -66,6 +66,10 @@ module IsoDoc::XrefGen
66
66
  "//sections/clause | //sections/definitions | "\
67
67
  "//bibliography/references | //bibliography/clause".freeze
68
68
 
69
+ def sections_xpath
70
+ SECTIONS_XPATH
71
+ end
72
+
69
73
  CHILD_NOTES_XPATH =
70
74
  "./*[not(self::xmlns:clause) and not(self::xmlns:appendix) and "\
71
75
  "not(self::xmlns:terms) and not(self::xmlns:definitions)]//xmlns:note | "\
@@ -123,9 +127,9 @@ module IsoDoc::XrefGen
123
127
  end
124
128
 
125
129
  def list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
126
- c = Counter.new
130
+ c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
127
131
  list.xpath(ns("./li")).each do |li|
128
- label = c.increment(li).listlabel(depth)
132
+ label = c.increment(li).listlabel(list, depth)
129
133
  label = "#{prev_label}.#{label}" unless prev_label.empty?
130
134
  label = "#{list_anchor[:xref]} #{label}" if refer_list
131
135
  li["id"] and @anchors[li["id"]] =
@@ -136,5 +140,19 @@ module IsoDoc::XrefGen
136
140
  end
137
141
  end
138
142
  end
143
+
144
+ def bookmark_anchor_names(sections)
145
+ sections.each do |s|
146
+ notes = s.xpath(ns(".//bookmark")) - s.xpath(ns(".//clause//bookmark")) -
147
+ s.xpath(ns(".//appendix//bookmark"))
148
+ notes.each do |n|
149
+ next if n["id"].nil? || n["id"].empty?
150
+ @anchors[n["id"]] = {
151
+ type: "bookmark", label: nil, value: nil,
152
+ xref: @anchors[s["id"]][:xref] }
153
+ end
154
+ bookmark_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
155
+ end
156
+ end
139
157
  end
140
158
  end
@@ -68,7 +68,7 @@ module IsoDoc::XrefGen
68
68
  end
69
69
 
70
70
  def clause_names(docxml, sect_num)
71
- docxml.xpath(ns(@klass.middle_clause)).each_with_index do |c, i|
71
+ docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, i|
72
72
  section_names(c, (i + sect_num), 1)
73
73
  end
74
74
  end
@@ -3,4 +3,18 @@
3
3
 
4
4
  p {
5
5
  font-family: $bodyfont;
6
+ font-size: $normalfontsize;
7
+ }
8
+ code {
9
+ font-family: $monospacefont;
10
+ font-size: $monospacefontsize;
11
+ }
12
+ aside {
13
+ font-size: $footnotefontsize;
14
+ }
15
+ h1 {
16
+ font-family: $headerfont;
17
+ }
18
+ p.note {
19
+ font-size: $smallerfontsize;
6
20
  }
@@ -1,22 +1,23 @@
1
- foreword: Antaŭparolo
1
+ foreword: Antaŭparolo
2
2
  introduction: Enkonduko
3
- clause: klaŭzo
4
- table: Tabelo
3
+ clause: klaŭzo
4
+ table: tabelo
5
5
  source: SOURCE
6
6
  modified: modified
7
7
  scope: Amplekso
8
8
  symbols: Simboloj kai mallongigitaj terminoj
9
9
  annex: Aldono
10
- normref: Normaj citaĵoj
10
+ normref: Normaj citaĵoj
11
11
  bibliography: Bibliografio
12
12
  inform_annex: informa
13
- all_parts: ĉiuj partoj
13
+ all_parts: ĉiuj partoj
14
14
  norm_annex: normative
15
+ note: NOTO
15
16
  locality: {
16
17
  table: Tabelo
17
18
  }
18
19
  doctype_dict: {
19
- brochure: broŝuro,
20
+ brochure: broŝuro,
20
21
  conference proceedings: konferencaktoj
21
22
  }
22
23
  stage_dict: {
@@ -534,7 +534,7 @@ INPUT
534
534
  <div>
535
535
  <h1 class='ForewordTitle'>Foreword</h1>
536
536
  <p id='A'>
537
- ABC
537
+ ABC
538
538
  <div id='B' class='Note'>
539
539
  <p>
540
540
  <span class='note_label'>NOTE 1</span>
@@ -1455,6 +1455,7 @@ end
1455
1455
  <div id='_be9158af-7e93-4ee2-90c5-26d31c181934' style='page-break-after: avoid;page-break-inside: avoid;'><div class='formula'>
1456
1456
  <p>
1457
1457
  <span class='stem'>(#(r = 1 %)#)</span>
1458
+ <span style='mso-tab-count:1'>&#160; </span>
1458
1459
  </p>
1459
1460
  </div>
1460
1461
  <p>where</p>
@@ -1186,5 +1186,4 @@ modified &mdash; with adjustments]
1186
1186
  </html>
1187
1187
  OUTPUT
1188
1188
  end
1189
-
1190
1189
  end
@@ -180,11 +180,10 @@ RSpec.describe IsoDoc do
180
180
  </div>
181
181
  <p class="zzSTDTitle1"></p>
182
182
  </main>
183
- <script type="text/x-mathjax-config">
184
- MathJax.Hub.Config({
185
- asciimath2jax: { delimiters: [['(#(', ')#)']] }
186
- });
187
- </script>
183
+ <script type='text/x-mathjax-config'>
184
+ MathJax.Hub.Config({ "HTML-CSS": { preferredFont: "STIX" }, asciimath2jax:
185
+ { delimiters: [['(#(', ')#)']] } });
186
+ </script>
188
187
  <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=MML_HTMLorMML-full" async="async"></script>
189
188
  <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script></body>
190
189
  OUTPUT
@@ -885,6 +885,8 @@ PRESXML
885
885
  <foreword obligation="informative">
886
886
  <title>Foreword</title>
887
887
  <p id="A">See <xref target="M"/></p>
888
+ <p id="A">See <xref target="tab"/></p>
889
+ <table id="tab"/>
888
890
  </foreword>
889
891
  <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
890
892
  <title>Introduction Subsection</title>
@@ -916,6 +918,7 @@ PRESXML
916
918
  </definitions>
917
919
  <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
918
920
  <title>Introduction</title>
921
+ <note id="M-n1"/>
919
922
  </clause>
920
923
  <clause id="O" inline-header="false" obligation="normative">
921
924
  <title>Clause 4.2</title>
@@ -971,7 +974,7 @@ PRESXML
971
974
  <localized-string key='foreword' language='eo'>Anta&#x16D;parolo</localized-string>
972
975
  <localized-string key='introduction' language='eo'>Enkonduko</localized-string>
973
976
  <localized-string key='clause' language='eo'>kla&#x16D;zo</localized-string>
974
- <localized-string key='table' language='eo'>Tabelo</localized-string>
977
+ <localized-string key='table' language='eo'>tabelo</localized-string>
975
978
  <localized-string key='source' language='eo'>SOURCE</localized-string>
976
979
  <localized-string key='modified' language='eo'>modified</localized-string>
977
980
  <localized-string key='scope' language='eo'>Amplekso</localized-string>
@@ -982,6 +985,7 @@ PRESXML
982
985
  <localized-string key='inform_annex' language='eo'>informa</localized-string>
983
986
  <localized-string key='all_parts' language='eo'>&#x109;iuj partoj</localized-string>
984
987
  <localized-string key='norm_annex' language='eo'>normative</localized-string>
988
+ <localized-string key='note' language='eo'>NOTO</localized-string>
985
989
  <localized-string key='locality.table' language='eo'>Tabelo</localized-string>
986
990
  <localized-string key='doctype_dict.brochure' language='eo'>bro&#x15D;uro</localized-string>
987
991
  <localized-string key='doctype_dict.conference_proceedings' language='eo'>konferencaktoj</localized-string>
@@ -998,6 +1002,10 @@ PRESXML
998
1002
  <foreword obligation="informative">
999
1003
  <title>Foreword</title>
1000
1004
  <p id='A'>See <xref target='M'>kla&#x16D;zo 5</xref></p>
1005
+ <p id='A'>See <xref target='tab'>tabelo 1</xref></p>
1006
+ <table id='tab'>
1007
+ <name>Tabelo 1</name>
1008
+ </table>
1001
1009
  </foreword>
1002
1010
  <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
1003
1011
  <title depth="2">Introduction Subsection</title>
@@ -1029,6 +1037,7 @@ PRESXML
1029
1037
  </definitions>
1030
1038
  <clause id="M" inline-header="false" obligation="normative"><title depth="1">5.<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
1031
1039
  <title depth="2">5.1.<tab/>Introduction</title>
1040
+ <note id='M-n1'><name>NOTO </name></note>
1032
1041
  </clause>
1033
1042
  <clause id="O" inline-header="false" obligation="normative">
1034
1043
  <title depth="2">5.2.<tab/>Clause 4.2</title>
@@ -1084,6 +1093,12 @@ PRESXML
1084
1093
  See
1085
1094
  <a href='#M'>kla&#365;zo 5</a>
1086
1095
  </p>
1096
+ <p id='A'>
1097
+ See
1098
+ <a href='#tab'>tabelo 1</a>
1099
+ </p>
1100
+ <p class='TableTitle' style='text-align:center;'>Tabelo 1</p>
1101
+ <table id='tab' class='MsoISOTable' style='border-width:1px;border-spacing:0;'/>
1087
1102
  </div>
1088
1103
  <br/>
1089
1104
  <div class='Section3' id='B'>
@@ -1136,6 +1151,12 @@ PRESXML
1136
1151
  <h1>5.&#160; Clause 4</h1>
1137
1152
  <div id='N'>
1138
1153
  <h2>5.1.&#160; Introduction</h2>
1154
+ <div id='M-n1' class='Note'>
1155
+ <p>
1156
+ <span class='note_label'>NOTO </span>
1157
+ &#160;
1158
+ </p>
1159
+ </div>
1139
1160
  </div>
1140
1161
  <div id='O'>
1141
1162
  <h2>5.2.&#160; Clause 4.2</h2>
@@ -1177,7 +1198,7 @@ PRESXML
1177
1198
  private
1178
1199
 
1179
1200
  def mock_i18n
1180
- allow_any_instance_of(::IsoDoc::I18n).to receive(:load_yaml).with("eo", "Latn", "spec/assets/i18n.yaml").and_return(YAML.load_file("spec/assets/i18n.yaml"))
1201
+ allow_any_instance_of(::IsoDoc::I18n).to receive(:load_yaml).with("eo", "Latn", "spec/assets/i18n.yaml").and_return(IsoDoc::I18n.new("eo", "Latn").normalise_hash(YAML.load_file("spec/assets/i18n.yaml")))
1181
1202
  end
1182
1203
 
1183
1204
  end
@@ -1,62 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
- it "cases xrefs" do
5
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({i18nyaml: "spec/assets/i18n.yaml"}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
- <iso-standard xmlns="http://riboseinc.com/isoxml">
7
- <sections>
8
- <clause id="A">
9
- <table id="B">
10
- </table>
11
- </clause>
12
- <clause id="C">
13
- <p>This is <xref target="A"/> and <xref target="B"/>.
14
- This is <xref target="A" case="capital"/> and <xref target="B" case="lowercase"/>.
15
- <xref target="A"/> is clause <em>initial.</em><br/>
16
- <xref target="A"/> is too. </p>
17
- <p><xref target="A"/> is also.</p>
18
- </clause>
19
- </sections>
20
- </iso-standard>
21
- INPUT
22
- <?xml version='1.0'?>
23
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
24
- <sections>
25
- <clause id='A'>
26
- <title>1.</title>
27
- <table id='B'>
28
- <name>Tabelo 1</name>
29
- </table>
30
- </clause>
31
- <clause id='C'>
32
- <title>2.</title>
33
- <p>
34
- This is
35
- <xref target='A'>kla&#x16D;zo 1</xref>
36
- and
37
- <xref target='B'>Tabelo 1</xref>
38
- . This is
39
- <xref target='A' case='capital'>Kla&#x16D;zo 1</xref>
40
- and
41
- <xref target='B' case='lowercase'>tabelo 1</xref>
42
- .
43
- <xref target='A'>Kla&#x16D;zo 1</xref>
44
- is clause
45
- <em>initial.</em>
46
- <br/>
47
- <xref target='A'>Kla&#x16D;zo 1</xref>
48
- is too.
49
- </p>
50
- <p>
51
- <xref target='A'>Kla&#x16D;zo 1</xref>
52
- is also.
53
- </p>
54
- </clause>
55
- </sections>
56
- </iso-standard>
57
- OUTPUT
58
- end
59
-
60
4
  it "droplocs xrefs" do
61
5
  expect(xmlpp(IsoDoc::PresentationXMLConvert.new({i18nyaml: "spec/assets/i18n.yaml"}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
62
6
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -99,14 +43,14 @@ INPUT
99
43
  OUTPUT
100
44
  end
101
45
 
102
- it "processes inline formatting" do
46
+ it "processes inline formatting (HTML)" do
103
47
  expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
104
48
  <iso-standard xmlns="http://riboseinc.com/isoxml">
105
49
  <preface><foreword>
106
50
  <p>
107
51
  <em>A</em> <strong>B</strong> <sup>C</sup> <sub>D</sub> <tt>E</tt>
108
52
  <strike>F</strike> <smallcap>G</smallcap> <keyword>I</keyword> <br/> <hr/>
109
- <bookmark id="H"/> <pagebreak/> <pagebreak orientation="landscape"/>
53
+ <bookmark id="H"/> <pagebreak/> <pagebreak orientation="landscape"/> <underline>J</underline>
110
54
  </p>
111
55
  </foreword></preface>
112
56
  <sections>
@@ -120,6 +64,7 @@ OUTPUT
120
64
  <i>A</i> <b>B</b> <sup>C</sup> <sub>D</sub> <tt>E</tt>
121
65
  <s>F</s> <span style="font-variant:small-caps;">G</span> <span class="keyword">I</span> <br/> <hr/>
122
66
  <a id="H"/> <br/> <br/>
67
+ <span style='text-decoration: underline;'>J</span>
123
68
  </p>
124
69
  </div>
125
70
  <p class="zzSTDTitle1"/>
@@ -136,7 +81,7 @@ OUTPUT
136
81
  <p>
137
82
  <em>A</em> <strong>B</strong> <sup>C</sup> <sub>D</sub> <tt>E</tt>
138
83
  <strike>F</strike> <smallcap>G</smallcap> <keyword>I</keyword> <br/> <hr/>
139
- <bookmark id="H"/> <pagebreak/> <pagebreak orientation="landscape"/>
84
+ <bookmark id="H"/> <pagebreak/> <pagebreak orientation="landscape"/> <underline>J</underline>
140
85
  </p>
141
86
  </clause></sections>
142
87
  </iso-standard>
@@ -163,6 +108,7 @@ OUTPUT
163
108
  <p>
164
109
  <br clear='all' class='section' orientation='landscape'/>
165
110
  </p>
111
+ <u>J</u>
166
112
  </p>
167
113
  </div>
168
114
  </div>
@@ -173,7 +119,7 @@ OUTPUT
173
119
  end
174
120
 
175
121
  it "ignores index entries" do
176
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
122
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
177
123
  <iso-standard xmlns="http://riboseinc.com/isoxml">
178
124
  <preface><foreword>
179
125
  <p><index primary="A" secondary="B" tertiary="C"/></p>
@@ -181,16 +127,14 @@ OUTPUT
181
127
  <sections>
182
128
  </iso-standard>
183
129
  INPUT
184
- #{HTML_HDR}
185
- <br/>
186
- <div>
187
- <h1 class='ForewordTitle'>Foreword</h1>
188
- <p/>
189
- </div>
190
- <p class='zzSTDTitle1'/>
191
- </div>
192
- </body>
193
- </html>
130
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
131
+ <preface>
132
+ <foreword>
133
+ <p/>
134
+ </foreword>
135
+ </preface>
136
+ <sections> </sections>
137
+ </iso-standard>
194
138
  OUTPUT
195
139
  end
196
140
 
@@ -280,119 +224,132 @@ OUTPUT
280
224
  </iso-standard>
281
225
  INPUT
282
226
  presxml = <<~OUTPUT
283
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
284
- <preface><foreword>
285
- <p>
286
- <ul>
287
- <li><concept term="term">
288
- <xref target="clause1">Clause 2</xref>
289
- </concept></li>
290
- <li><concept term="term">
291
- <xref target="clause1">w[o]rd</xref>
292
- </concept></li>
293
- <li><concept term="term">
294
- <eref bibitemid="ISO712" type="inline" citeas="ISO 712">ISO 712</eref>
295
- </concept></li>
296
- <li><concept term="term">
297
- <eref bibitemid="ISO712" type="inline" citeas="ISO 712">word</eref>
298
- </concept></li>
299
- <li><concept>
300
- <eref bibitemid="ISO712" type="inline" citeas="ISO 712"><locality type="clause">
301
- <referenceFrom>3.1</referenceFrom>
302
- </locality><locality type="figure">
303
- <referenceFrom>a</referenceFrom>
304
- </locality>ISO 712, Clause 3.1, Figure a</eref>
305
- </concept></li>
306
- <li><concept>
307
- <eref bibitemid="ISO712" type="inline" citeas="ISO 712"><localityStack>
308
- <locality type="clause">
309
- <referenceFrom>3.1</referenceFrom>
310
- </locality>
311
- </localityStack><localityStack>
312
- <locality type="figure">
313
- <referenceFrom>b</referenceFrom>
314
- </locality>
315
- </localityStack>ISO 712, Clause 3.1; Figure b</eref>
316
- </concept></li>
317
- <li><concept>
318
- <eref bibitemid="ISO712" type="inline" citeas="ISO 712">
319
- <localityStack>
320
- <locality type="clause">
321
- <referenceFrom>3.1</referenceFrom>
322
- </locality>
323
- </localityStack>
324
- <localityStack>
325
- <locality type="figure">
326
- <referenceFrom>b</referenceFrom>
327
- </locality>
328
- </localityStack>
329
- <em>word</em>
330
- </eref>
331
- </concept></li>
332
- <li><concept term="term">
333
- <termref base="IEV" target="135-13-13"/>
334
- </concept></li>
335
- <li><concept term="term">
336
- <termref base="IEV" target="135-13-13"><em>word</em> word</termref>
337
- </concept></li>
338
- </ul>
339
- </p>
340
- </foreword></preface>
341
- <sections>
342
- <clause id="clause1"><title depth='1'>2.<tab/>Clause 1</title>
343
- </clause>
344
- </sections>
345
- <bibliography><references id="_normative_references" obligation="informative" normative="true">
346
- <title depth='1'>1.<tab/>Normative References</title>
347
- <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
348
- <bibitem id="ISO712" type="standard">
349
- <title format="text/plain">Cereals or cereal products</title>
350
- <title type="main" format="text/plain">Cereals and cereal products</title>
351
- <docidentifier type="ISO">ISO 712</docidentifier>
352
- <contributor>
353
- <role type="publisher"/>
354
- <organization>
355
- <name>International Organization for Standardization</name>
356
- </organization>
357
- </contributor>
358
- </bibitem>
359
- </references></bibliography>
360
- </iso-standard>
361
- OUTPUT
362
-
363
- html = <<~OUTPUT
364
- #{HTML_HDR}
365
- <br/>
366
- <div>
367
- <h1 class="ForewordTitle">Foreword</h1>
368
- <p>
369
- <ul>
370
- <li>Clause 2</li>
371
- <li>w[o]rd</li>
372
- <li>ISO 712</li>
373
- <li>word</li>
374
- <li>ISO 712, Clause 3.1, Figure a</li>
375
- <li>ISO 712, Clause 3.1; Figure b</li>
376
- <li><i>word</i></li>
377
- <li>[Term defined in Termbase IEV, term ID 135-13-13]</li>
378
- <li><i>word</i> word</li>
379
- </ul>
380
- </p>
381
- </div>
382
- <p class="zzSTDTitle1"/>
383
- <div><h1>1.&#160; Normative References</h1>
384
- <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
385
- <p id="ISO712" class="NormRef">ISO 712, <i>Cereals and cereal products</i></p>
386
- </div>
387
- <div id="clause1">
388
- <h1>2.&#160; Clause 1</h1>
389
- </div>
390
- </div>
391
- </body>
392
- </html>
393
- OUTPUT
394
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml)
395
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html)
227
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
228
+ <preface>
229
+ <foreword>
230
+ <p>
231
+ <ul>
232
+ <li>
233
+ <em>
234
+ <xref target='clause1'>Clause 2</xref>
235
+ </em>
236
+ </li>
237
+ <li>
238
+ <em>
239
+ <xref target='clause1'>w[o]rd</xref>
240
+ </em>
241
+ </li>
242
+ <li>
243
+ <em>
244
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>ISO 712</eref>
245
+ </em>
246
+ </li>
247
+ <li>
248
+ <em>
249
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>word</eref>
250
+ </em>
251
+ </li>
252
+ <li>
253
+ <em>
254
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
255
+ <locality type='clause'>
256
+ <referenceFrom>3.1</referenceFrom>
257
+ </locality>
258
+ <locality type='figure'>
259
+ <referenceFrom>a</referenceFrom>
260
+ </locality>
261
+ ISO 712, Clause 3.1, Figure a
262
+ </eref>
263
+ </em>
264
+ </li>
265
+ <li>
266
+ <em>
267
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
268
+ <localityStack>
269
+ <locality type='clause'>
270
+ <referenceFrom>3.1</referenceFrom>
271
+ </locality>
272
+ </localityStack>
273
+ <localityStack>
274
+ <locality type='figure'>
275
+ <referenceFrom>b</referenceFrom>
276
+ </locality>
277
+ </localityStack>
278
+ ISO 712, Clause 3.1; Figure b
279
+ </eref>
280
+ </em>
281
+ </li>
282
+ <li>
283
+ <em>
284
+ <eref bibitemid='ISO712' type='inline' citeas='ISO 712'>
285
+ <localityStack>
286
+ <locality type='clause'>
287
+ <referenceFrom>3.1</referenceFrom>
288
+ </locality>
289
+ </localityStack>
290
+ <localityStack>
291
+ <locality type='figure'>
292
+ <referenceFrom>b</referenceFrom>
293
+ </locality>
294
+ </localityStack>
295
+ <em>word</em>
296
+ </eref>
297
+ </em>
298
+ </li>
299
+ <li>
300
+ [term defined in
301
+ <termref base='IEV' target='135-13-13'/>
302
+ ]
303
+ </li>
304
+ <li>
305
+ <em>
306
+ <termref base='IEV' target='135-13-13'>
307
+ <em>word</em>
308
+ word
309
+ </termref>
310
+ </em>
311
+ </li>
312
+ </ul>
313
+ </p>
314
+ </foreword>
315
+ </preface>
316
+ <sections>
317
+ <clause id='clause1'>
318
+ <title depth='1'>
319
+ 2.
320
+ <tab/>
321
+ Clause 1
322
+ </title>
323
+ </clause>
324
+ </sections>
325
+ <bibliography>
326
+ <references id='_normative_references' obligation='informative' normative='true'>
327
+ <title depth='1'>
328
+ 1.
329
+ <tab/>
330
+ Normative References
331
+ </title>
332
+ <p>
333
+ The following documents are referred to in the text in such a way that
334
+ some or all of their content constitutes requirements of this document.
335
+ For dated references, only the edition cited applies. For undated
336
+ references, the latest edition of the referenced document (including any
337
+ amendments) applies.
338
+ </p>
339
+ <bibitem id='ISO712' type='standard'>
340
+ <title format='text/plain'>Cereals or cereal products</title>
341
+ <title type='main' format='text/plain'>Cereals and cereal products</title>
342
+ <docidentifier type='ISO'>ISO 712</docidentifier>
343
+ <contributor>
344
+ <role type='publisher'/>
345
+ <organization>
346
+ <name>International Organization for Standardization</name>
347
+ </organization>
348
+ </contributor>
349
+ </bibitem>
350
+ </references>
351
+ </bibliography>
352
+ </iso-standard>
396
353
  end
397
354
 
398
355
  it "processes embedded inline formatting" do
@@ -945,7 +902,7 @@ OUTPUT
945
902
  end
946
903
 
947
904
  it "processes variant" do
948
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
905
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).sub(%r{<localized-strings>.*</localized-strings>}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
949
906
  <iso-standard xmlns="http://riboseinc.com/isoxml">
950
907
  <bibdata>
951
908
  <language>en</language>
@@ -953,28 +910,46 @@ OUTPUT
953
910
  </bibdata>
954
911
  <preface>
955
912
  <clause id="A"><title><variant lang="en" script="Latn">ABC</variant><variant lang="fr" script="Latn">DEF</variant></title></clause>
913
+ <clause id="A1"><title><variant lang="en" script="Grek">ABC</variant><variant lang="fr" script="Grek">DEF</variant></title></clause>
914
+ <clause id="A2"><title><variant lang="en">ABC</variant><variant lang="fr">DEF</variant></title></clause>
956
915
  <clause id="B"><title><variant lang="de" script="Latn">GHI</variant><variant lang="es" script="Latn">JKL</variant></title></clause>
957
916
  <clause id="C"><title><variant lang="fr" script="Latn">ABC</variant><variant lang="en" script="Latn">DEF</variant></title></clause>
917
+ <clause id="C1"><title><variant lang="fr" script="Grek">ABC</variant><variant lang="en" script="Grek">DEF</variant></title></clause>
918
+ <clause id="C2"><title><variant lang="fr">ABC</variant><variant lang="en">DEF</variant></title></clause>
919
+ <p>A <variant><variant lang="en">B</variant><variant lang="fr">C</variant></variant> D <variant><variant lang="en" script="Latn">E</variant><variant lang="fr" script="Latn">F</variant></variant></p>
958
920
  </preface>
959
921
  </iso-standard>
960
922
  INPUT
961
- #{HTML_HDR}
962
- <br/>
963
- <div class='Section3' id='A'>
964
- <h1 class='IntroTitle'>ABC</h1>
965
- </div>
966
- <br/>
967
- <div class='Section3' id='B'>
968
- <h1 class='IntroTitle'>GHI</h1>
969
- </div>
970
- <br/>
971
- <div class='Section3' id='C'>
972
- <h1 class='IntroTitle'>DEF</h1>
973
- </div>
974
- <p class='zzSTDTitle1'/>
975
- </div>
976
- </body>
977
- </html>
923
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
924
+ <bibdata>
925
+ <language current='true'>en</language>
926
+ <script current='true'>Latn</script>
927
+ </bibdata>
928
+ <preface>
929
+ <clause id='A'>
930
+ <title depth='1'>ABC</title>
931
+ </clause>
932
+ <clause id='A1'>
933
+ <title depth='1'>ABC/DEF</title>
934
+ </clause>
935
+ <clause id='A2'>
936
+ <title depth='1'>ABC</title>
937
+ </clause>
938
+ <clause id='B'>
939
+ <title depth='1'>GHI/JKL</title>
940
+ </clause>
941
+ <clause id='C'>
942
+ <title depth='1'>DEF</title>
943
+ </clause>
944
+ <clause id='C1'>
945
+ <title depth='1'>ABC/DEF</title>
946
+ </clause>
947
+ <clause id='C2'>
948
+ <title depth='1'>DEF</title>
949
+ </clause>
950
+ <p>A B D E</p>
951
+ </preface>
952
+ </iso-standard>
978
953
  OUTPUT
979
954
  end
980
955
 
@@ -989,6 +964,7 @@ it "cases xrefs" do
989
964
  <clause id="C">
990
965
  <p>This is <xref target="A"/> and <xref target="B"/>.
991
966
  This is <xref target="A" case="capital"/> and <xref target="B" case="lowercase"/>.
967
+ This is <xref target="A" case="lowercase"/> and <xref target="B" case="capital"/>.
992
968
  <xref target="A"/> is clause <em>initial.</em><br/>
993
969
  <xref target="A"/> is too. </p>
994
970
  <p><xref target="A"/> is also.</p>
@@ -1011,11 +987,15 @@ INPUT
1011
987
  This is
1012
988
  <xref target='A'>kla&#x16D;zo 1</xref>
1013
989
  and
1014
- <xref target='B'>Tabelo 1</xref>
990
+ <xref target='B'>tabelo 1</xref>
1015
991
  . This is
1016
992
  <xref target='A' case='capital'>Kla&#x16D;zo 1</xref>
1017
993
  and
1018
994
  <xref target='B' case='lowercase'>tabelo 1</xref>
995
+ . This is
996
+ <xref target='A' case='lowercase'>kla&#x16D;zo 1</xref>
997
+ and
998
+ <xref target='B' case='capital'>Tabelo 1</xref>
1019
999
  .
1020
1000
  <xref target='A'>Kla&#x16D;zo 1</xref>
1021
1001
  is clause