isodoc 1.5.2 → 1.6.1

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -1
  3. data/.rubocop.yml +6 -2
  4. data/Gemfile +2 -2
  5. data/bin/rspec +1 -2
  6. data/isodoc.gemspec +11 -11
  7. data/lib/isodoc/base_style/all.css +7 -0
  8. data/lib/isodoc/base_style/metanorma_word.css +7 -0
  9. data/lib/isodoc/base_style/metanorma_word.scss +8 -0
  10. data/lib/isodoc/base_style/reset.css +7 -0
  11. data/lib/isodoc/base_style/reset.scss +9 -0
  12. data/lib/isodoc/base_style/scripts.html +187 -0
  13. data/lib/isodoc/class_utils.rb +6 -5
  14. data/lib/isodoc/convert.rb +30 -17
  15. data/lib/isodoc/css.rb +42 -28
  16. data/lib/isodoc/function/blocks.rb +15 -4
  17. data/lib/isodoc/function/blocks_example_note.rb +2 -2
  18. data/lib/isodoc/function/cleanup.rb +1 -2
  19. data/lib/isodoc/function/inline.rb +31 -10
  20. data/lib/isodoc/function/references.rb +1 -1
  21. data/lib/isodoc/function/to_word_html.rb +19 -8
  22. data/lib/isodoc/function/utils.rb +41 -38
  23. data/lib/isodoc/gem_tasks.rb +30 -31
  24. data/lib/isodoc/html_convert.rb +4 -4
  25. data/lib/isodoc/html_function/postprocess.rb +35 -76
  26. data/lib/isodoc/html_function/postprocess_footnotes.rb +59 -0
  27. data/lib/isodoc/i18n.rb +20 -20
  28. data/lib/isodoc/pdf_convert.rb +1 -3
  29. data/lib/isodoc/presentation_function/block.rb +26 -11
  30. data/lib/isodoc/presentation_function/inline.rb +44 -38
  31. data/lib/isodoc/presentation_xml_convert.rb +1 -1
  32. data/lib/isodoc/version.rb +1 -1
  33. data/lib/isodoc/word_function/footnotes.rb +22 -15
  34. data/lib/isodoc/word_function/inline.rb +6 -0
  35. data/lib/isodoc/word_function/postprocess.rb +16 -6
  36. data/lib/isodoc/xref.rb +10 -11
  37. data/lib/isodoc/xref/xref_counter.rb +31 -15
  38. data/lib/isodoc/xref/xref_gen.rb +28 -22
  39. data/lib/isodoc/xref/xref_sect_gen.rb +22 -20
  40. data/lib/isodoc/xslfo_convert.rb +36 -25
  41. data/spec/assets/html_override.css +1 -0
  42. data/spec/assets/word_override.css +1 -0
  43. data/spec/isodoc/blocks_spec.rb +2599 -2503
  44. data/spec/isodoc/cleanup_spec.rb +1107 -1109
  45. data/spec/isodoc/footnotes_spec.rb +1 -16
  46. data/spec/isodoc/i18n_spec.rb +984 -972
  47. data/spec/isodoc/inline_spec.rb +34 -0
  48. data/spec/isodoc/lists_spec.rb +316 -315
  49. data/spec/isodoc/postproc_spec.rb +1655 -1521
  50. data/spec/isodoc/presentation_xml_spec.rb +345 -338
  51. data/spec/isodoc/ref_spec.rb +718 -723
  52. data/spec/isodoc/section_spec.rb +910 -902
  53. data/spec/isodoc/table_spec.rb +566 -556
  54. data/spec/isodoc/terms_spec.rb +252 -256
  55. data/spec/isodoc/xref_spec.rb +3040 -2985
  56. data/spec/isodoc/xslfo_convert_spec.rb +39 -0
  57. data/spec/spec_helper.rb +30 -29
  58. metadata +72 -69
  59. data/.rubocop.ribose.yml +0 -65
  60. data/.rubocop.tb.yml +0 -650
data/lib/isodoc/xref.rb CHANGED
@@ -11,7 +11,7 @@ module IsoDoc
11
11
  include XrefGen::Blocks
12
12
  include XrefGen::Sections
13
13
 
14
- def initialize(lang, script, klass, i18n, options = {})
14
+ def initialize(lang, script, klass, i18n, options = {})
15
15
  @anchors = {}
16
16
  @lang = lang
17
17
  @script = script
@@ -28,13 +28,12 @@ module IsoDoc
28
28
 
29
29
  def anchor(id, lbl, warning = true)
30
30
  return nil if id.nil? || id.empty?
31
- unless @anchors[id]
32
- if warning
33
- @seen ||= Seen_Anchor.instance
34
- @seen.seen(id) or warn "No label has been processed for ID #{id}"
35
- @seen.add(id)
36
- return "[#{id}]"
37
- end
31
+
32
+ if warning && !@anchors[id]
33
+ @seen ||= Seen_Anchor.instance
34
+ @seen.seen(id) or warn "No label has been processed for ID #{id}"
35
+ @seen.add(id)
36
+ return "[#{id}]"
38
37
  end
39
38
  @anchors.dig(id, lbl)
40
39
  end
@@ -49,15 +48,15 @@ module IsoDoc
49
48
  note_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
50
49
  example_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
51
50
  list_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
52
- bookmark_anchor_names(docxml.xpath(ns(SECTIONS_XPATH)))
51
+ bookmark_anchor_names(docxml)
53
52
  end
54
53
 
55
54
  def ns(xpath)
56
55
  Common::ns(xpath)
57
56
  end
58
57
 
59
- def l10n(a, lang = @lang, script = @script)
60
- @i18n.l10n(a, lang, script)
58
+ def l10n(text, lang = @lang, script = @script)
59
+ @i18n.l10n(text, lang, script)
61
60
  end
62
61
  end
63
62
  end
@@ -2,16 +2,17 @@ require "roman-numerals"
2
2
 
3
3
  module IsoDoc::XrefGen
4
4
  class Counter
5
- def initialize(num = 0, opts = {numerals: :arabic})
5
+ def initialize(num = 0, opts = { numerals: :arabic })
6
6
  @num = num
7
7
  @letter = ""
8
8
  @subseq = ""
9
9
  @letter_override = nil
10
10
  @number_override = nil
11
11
  @style = opts[:numerals]
12
+ @skip_i = opts[:skip_i]
12
13
  @base = ""
13
14
  if num.is_a? String
14
- if /^\d+$/.match(num)
15
+ if /^\d+$/.match?(num)
15
16
  @num = num.to_i
16
17
  else
17
18
  @num = nil
@@ -34,7 +35,7 @@ module IsoDoc::XrefGen
34
35
  @base = b
35
36
  else
36
37
  @letter_override = node["number"]
37
- @letter = @letter_override if /^[a-zA-Z]$/.match(@letter_override)
38
+ @letter = @letter_override if /^[a-zA-Z]$/.match?(@letter_override)
38
39
  end
39
40
  end
40
41
  end
@@ -64,7 +65,7 @@ module IsoDoc::XrefGen
64
65
  @letter_override = node["number"]
65
66
  /^(?<b>.*?)(?<n>\d*)(?<a>[a-zA-Z])$/ =~ node["number"]
66
67
  if blank?(a)
67
- if /^\d+$/.match(node["number"])
68
+ if /^\d+$/.match?(node["number"])
68
69
  @letter_override = @letter = ""
69
70
  @number_override = @num = node["number"].to_i
70
71
  else
@@ -80,32 +81,46 @@ module IsoDoc::XrefGen
80
81
  @number_override = @num = n.to_i unless n.empty?
81
82
  end
82
83
  else
83
- @letter = (@letter.ord + 1).chr.to_s
84
+ increment_letter
85
+ end
86
+ end
87
+
88
+ def increment_letter
89
+ case @letter
90
+ when "Z"
91
+ @letter = "@"
92
+ @base = @base.empty? ? "A" : @base[0..-2] + (@base[-1].ord + 1).chr.to_s
93
+ when "z"
94
+ @letter = "`"
95
+ @base = @base.empty? ? "a" : @base[0..-2] + (@base[-1].ord + 1).chr.to_s
84
96
  end
97
+ @letter = (@letter.ord + 1).chr.to_s
98
+ @skip_i && %w(i I).include?(@letter) and
99
+ @letter = (@letter.ord + 1).chr.to_s
85
100
  end
86
101
 
87
- def blank?(x)
88
- x.nil? || x.empty?
102
+ def blank?(str)
103
+ str.nil? || str.empty?
89
104
  end
90
105
 
91
106
  def increment(node)
92
107
  return self if node["unnumbered"]
108
+
93
109
  @letter_override = nil
94
110
  @number_override = nil
95
- if node["subsequence"] != @subseq && !(blank?(node["subsequence"]) && blank?(@subseq))
111
+ if node["subsequence"] != @subseq &&
112
+ !(blank?(node["subsequence"]) && blank?(@subseq))
96
113
  new_subseq_increment(node)
97
- elsif @letter.empty?
98
- sequence_increment(node)
99
- else
100
- subsequence_increment(node)
114
+ elsif @letter.empty? then sequence_increment(node)
115
+ else subsequence_increment(node)
101
116
  end
102
117
  self
103
118
  end
104
119
 
105
120
  def print
106
121
  num = @number_override || @num
107
- num_out = @style == :roman && !num.nil? ? RomanNumerals.to_roman(num) : num
108
- "#{@base}#{num_out}#{@letter_override || @letter}"
122
+ out = @style == :roman && !num.nil? ? RomanNumerals.to_roman(num) : num
123
+ "#{@base}#{out}#{@letter_override || @letter}"
109
124
  end
110
125
 
111
126
  def ol_type(list, depth)
@@ -115,7 +130,8 @@ module IsoDoc::XrefGen
115
130
  return :alphabet_upper if [4, 9].include? depth
116
131
  return :roman if [3, 8].include? depth
117
132
  return :roman_upper if [5, 10].include? depth
118
- return :arabic
133
+
134
+ :arabic
119
135
  end
120
136
 
121
137
  def listlabel(list, depth)
@@ -1,4 +1,4 @@
1
- require_relative "xref_gen_seq.rb"
1
+ require_relative "xref_gen_seq"
2
2
 
3
3
  module IsoDoc::XrefGen
4
4
  module Blocks
@@ -17,23 +17,24 @@ module IsoDoc::XrefGen
17
17
  end
18
18
  end
19
19
 
20
- def amend_autonums(a)
20
+ def amend_autonums(amend)
21
21
  autonum = {}
22
- a.xpath(ns("./autonumber")).each do |n|
22
+ amend.xpath(ns("./autonumber")).each do |n|
23
23
  autonum[n["type"]] = n.text
24
24
  end
25
25
  autonum
26
26
  end
27
27
 
28
- def termnote_label(n)
29
- @labels["termnote"].gsub(/%/, n.to_s)
28
+ def termnote_label(note)
29
+ @labels["termnote"].gsub(/%/, note.to_s)
30
30
  end
31
31
 
32
32
  def termnote_anchor_names(docxml)
33
33
  docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
34
34
  c = Counter.new
35
35
  t.xpath(ns(".//termnote")).each do |n|
36
- return if n["id"].nil? || n["id"].empty?
36
+ next if n["id"].nil? || n["id"].empty?
37
+
37
38
  c.increment(n)
38
39
  @anchors[n["id"]] =
39
40
  { label: termnote_label(c.print), type: "termnote", value: c.print,
@@ -48,7 +49,8 @@ module IsoDoc::XrefGen
48
49
  examples = t.xpath(ns(".//termexample"))
49
50
  c = Counter.new
50
51
  examples.each do |n|
51
- return if n["id"].nil? || n["id"].empty?
52
+ next if n["id"].nil? || n["id"].empty?
53
+
52
54
  c.increment(n)
53
55
  idx = examples.size == 1 && !n["number"] ? "" : c.print
54
56
  @anchors[n["id"]] = {
@@ -81,6 +83,7 @@ module IsoDoc::XrefGen
81
83
  c = Counter.new
82
84
  notes.each do |n|
83
85
  next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
86
+
84
87
  idx = notes.size == 1 && !n["number"] ? "" : " #{c.increment(n).print}"
85
88
  @anchors[n["id"]] = anchor_struct(idx, n, @labels["note_xref"],
86
89
  "note", false)
@@ -94,16 +97,18 @@ module IsoDoc::XrefGen
94
97
  "not(self::xmlns:terms) and not(self::xmlns:definitions)]//"\
95
98
  "xmlns:example | ./xmlns:example".freeze
96
99
 
97
- CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | ./references"
100
+ CHILD_SECTIONS = "./clause | ./appendix | ./terms | ./definitions | "\
101
+ "./references"
98
102
 
99
103
  def example_anchor_names(sections)
100
104
  sections.each do |s|
101
105
  notes = s.xpath(CHILD_EXAMPLES_XPATH)
102
106
  c = Counter.new
103
107
  notes.each do |n|
104
- next if @anchors[n["id"]]
105
- next if n["id"].nil? || n["id"].empty?
106
- idx = notes.size == 1 && !n["number"] ? "" : " #{c.increment(n).print}"
108
+ next if @anchors[n["id"]] || n["id"].nil? || n["id"].empty?
109
+
110
+ idx = notes.size == 1 && !n["number"] ? "" :
111
+ " #{c.increment(n).print}"
107
112
  @anchors[n["id"]] = anchor_struct(idx, n, @labels["example_xref"],
108
113
  "example", n["unnumbered"])
109
114
  end
@@ -118,8 +123,10 @@ module IsoDoc::XrefGen
118
123
  c = Counter.new
119
124
  notes.each do |n|
120
125
  next if n["id"].nil? || n["id"].empty?
126
+
121
127
  idx = notes.size == 1 && !n["number"] ? "" : " #{c.increment(n).print}"
122
- @anchors[n["id"]] = anchor_struct(idx, n, @labels["list"], "list", false)
128
+ @anchors[n["id"]] = anchor_struct(idx, n, @labels["list"], "list",
129
+ false)
123
130
  list_item_anchor_names(n, @anchors[n["id"]], 1, "", notes.size != 1)
124
131
  end
125
132
  list_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
@@ -141,17 +148,16 @@ module IsoDoc::XrefGen
141
148
  end
142
149
  end
143
150
 
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] }
151
+ def bookmark_anchor_names(docxml)
152
+ docxml.xpath(ns(".//bookmark")).each do |n|
153
+ next if n["id"].nil? || n["id"].empty?
154
+ parent = nil
155
+ n.ancestors.each do |a|
156
+ next unless a["id"] && parent = @anchors.dig(a["id"], :xref)
157
+ break
153
158
  end
154
- bookmark_anchor_names(s.xpath(ns(CHILD_SECTIONS)))
159
+ @anchors[n["id"]] = { type: "bookmark", label: nil, value: nil,
160
+ xref: parent || "???" }
155
161
  end
156
162
  end
157
163
  end
@@ -30,9 +30,8 @@ module IsoDoc::XrefGen
30
30
  termexample_anchor_names(d)
31
31
  end
32
32
 
33
- def preface_clause_name(c)
34
- ret = c.at(ns("./title"))&.text || c.name.capitalize
35
- ret
33
+ def preface_clause_name(clause)
34
+ clause.at(ns("./title"))&.text || clause.name.capitalize
36
35
  end
37
36
 
38
37
  SUBCLAUSES =
@@ -41,12 +40,13 @@ module IsoDoc::XrefGen
41
40
  # in StanDoc, prefaces have no numbering; they are referenced only by title
42
41
  def preface_names(clause)
43
42
  return if clause.nil?
43
+
44
44
  @anchors[clause["id"]] =
45
45
  { label: nil, level: 1, xref: preface_clause_name(clause),
46
46
  type: "clause" }
47
47
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
48
48
  preface_names1(c, c.at(ns("./title"))&.text,
49
- "#{preface_clause_name(clause)}, #{i+1}", 2)
49
+ "#{preface_clause_name(clause)}, #{i + 1}", 2)
50
50
  end
51
51
  end
52
52
 
@@ -55,7 +55,7 @@ module IsoDoc::XrefGen
55
55
  @anchors[clause["id"]] =
56
56
  { label: nil, level: level, xref: label, type: "clause" }
57
57
  clause.xpath(ns(SUBCLAUSES)).each_with_index do |c, i|
58
- preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i+1}",
58
+ preface_names1(c, c.at(ns("./title"))&.text, "#{label} #{i + 1}",
59
59
  level + 1)
60
60
  end
61
61
  end
@@ -69,17 +69,18 @@ module IsoDoc::XrefGen
69
69
  end
70
70
 
71
71
  def clause_names(docxml, n)
72
- docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, i|
72
+ docxml.xpath(ns(@klass.middle_clause(docxml))).each_with_index do |c, _i|
73
73
  section_names(c, n, 1)
74
74
  end
75
75
  end
76
76
 
77
77
  def section_names(clause, num, lvl)
78
78
  return num if clause.nil?
79
+
79
80
  num.increment(clause)
80
81
  @anchors[clause["id"]] =
81
- { label: num.print, xref: l10n("#{@labels["clause"]} #{num.print}"), level: lvl,
82
- type: "clause" }
82
+ { label: num.print, xref: l10n("#{@labels['clause']} #{num.print}"),
83
+ level: lvl, type: "clause" }
83
84
  i = Counter.new
84
85
  clause.xpath(ns(SUBCLAUSES)).each do |c|
85
86
  i.increment(c)
@@ -90,7 +91,7 @@ module IsoDoc::XrefGen
90
91
 
91
92
  def section_names1(clause, num, level)
92
93
  @anchors[clause["id"]] =
93
- { label: num, level: level, xref: l10n("#{@labels["clause"]} #{num}"),
94
+ { label: num, level: level, xref: l10n("#{@labels['clause']} #{num}"),
94
95
  type: "clause" }
95
96
  i = Counter.new
96
97
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -100,26 +101,27 @@ module IsoDoc::XrefGen
100
101
  end
101
102
 
102
103
  def annex_name_lbl(clause, num)
103
- obl = l10n("(#{@labels["inform_annex"]})")
104
- obl = l10n("(#{@labels["norm_annex"]})") if clause["obligation"] == "normative"
105
- l10n("<strong>#{@labels["annex"]} #{num}</strong><br/>#{obl}")
104
+ obl = l10n("(#{@labels['inform_annex']})")
105
+ clause["obligation"] == "normative" and
106
+ obl = l10n("(#{@labels['norm_annex']})")
107
+ l10n("<strong>#{@labels['annex']} #{num}</strong><br/>#{obl}")
106
108
  end
107
109
 
108
110
  def single_annex_special_section(clause)
109
111
  a = clause.xpath(ns("./references | ./terms | ./definitions"))
110
112
  a.size == 1 or return nil
111
113
  clause.xpath(ns("./clause | ./p | ./table | ./ol | ./ul | ./dl | "\
112
- "./note | ./admonition | ./figure")).size == 0 or
113
- return nil
114
+ "./note | ./admonition | ./figure")).empty? or
115
+ return nil
114
116
  a[0]
115
117
  end
116
118
 
117
119
  def annex_names(clause, num)
118
120
  @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
119
121
  type: "clause", value: num.to_s,
120
- xref: "#{@labels["annex"]} #{num}", level: 1 }
122
+ xref: "#{@labels['annex']} #{num}", level: 1 }
121
123
  if a = single_annex_special_section(clause)
122
- annex_names1(a, "#{num}", 1)
124
+ annex_names1(a, num.to_s, 1)
123
125
  else
124
126
  i = Counter.new
125
127
  clause.xpath(ns(SUBCLAUSES)).each do |c|
@@ -131,10 +133,10 @@ module IsoDoc::XrefGen
131
133
  end
132
134
 
133
135
  def annex_names1(clause, num, level)
134
- @anchors[clause["id"]] = { label: num, xref: "#{@labels["annex"]} #{num}",
136
+ @anchors[clause["id"]] = { label: num, xref: "#{@labels['annex']} #{num}",
135
137
  level: level, type: "clause" }
136
138
  i = Counter.new
137
- clause.xpath(ns(SUBCLAUSES)).each_with_index do |c|
139
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
138
140
  i.increment(c)
139
141
  annex_names1(c, "#{num}.#{i.print}", level + 1)
140
142
  end
@@ -147,10 +149,10 @@ module IsoDoc::XrefGen
147
149
  "xmlns:name = 'International Electrotechnical Commission']".freeze
148
150
 
149
151
  def reference_names(ref)
150
- isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
152
+ # isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
151
153
  ids = @klass.bibitem_ref_code(ref)
152
154
  identifiers = @klass.render_identifier(ids)
153
- date = ref.at(ns("./date[@type = 'published']"))
155
+ # date = ref.at(ns("./date[@type = 'published']"))
154
156
  reference = @klass.docid_l10n(identifiers[0] || identifiers[1])
155
157
  @anchors[ref["id"]] = { xref: reference }
156
158
  end
@@ -2,50 +2,61 @@ require "metanorma"
2
2
 
3
3
  module IsoDoc
4
4
  class XslfoPdfConvert < ::IsoDoc::Convert
5
+ MN2PDF_OPTIONS = :mn2pdf
6
+ MN2PDF_FONT_MANIFEST = :font_manifest_file
5
7
 
6
8
  def initialize(options)
9
+ @format = :pdf
10
+ @suffix = "pdf"
7
11
  super
8
- @maxwidth = 500
9
- @maxheight = 800
10
12
  end
11
13
 
12
14
  def tmpimagedir_suffix
13
15
  "_pdfimages"
14
16
  end
15
17
 
16
- def initialize(options)
17
- @format = :pdf
18
- @suffix = "pdf"
19
- super
20
- end
21
-
22
- def pdf_stylesheet(docxml)
18
+ def pdf_stylesheet(_docxml)
23
19
  nil
24
20
  end
25
21
 
26
- def pdf_options(docxml)
27
- ""
22
+ def pdf_options(_docxml)
23
+ if font_manifest_file = @options.dig(MN2PDF_OPTIONS,
24
+ MN2PDF_FONT_MANIFEST)
25
+ "--font-manifest #{font_manifest_file}"
26
+ else
27
+ ""
28
+ end
28
29
  end
29
30
 
30
- def convert(input_filename, file = nil, debug = false, output_filename = nil)
31
+ def convert(input_filename, file = nil, debug = false,
32
+ output_filename = nil)
31
33
  file = File.read(input_filename, encoding: "utf-8") if file.nil?
32
- docxml, filename, dir = convert_init(file, input_filename, debug)
33
- /\.xml$/.match(input_filename) or
34
- input_filename = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
35
- f.write file
34
+ input_filename, docxml, filename = input_xml_path(input_filename,
35
+ file, debug)
36
+ ::Metanorma::Output::XslfoPdf.new.convert(
37
+ input_filename,
38
+ output_filename || "#{filename}.#{@suffix}",
39
+ File.join(@libdir, pdf_stylesheet(docxml)),
40
+ pdf_options(docxml)
41
+ )
42
+ end
43
+
44
+ def xref_parse(node, out)
45
+ out.a(**{ "href": target_pdf(node) }) { |l| l << get_linkend(node) }
46
+ end
47
+
48
+ def input_xml_path(input_filename, xml_file, debug)
49
+ docxml, filename, dir = convert_init(xml_file, input_filename, debug)
50
+ unless /\.xml$/.match?(input_filename)
51
+ input_filename = Tempfile.open([filename, ".xml"],
52
+ encoding: "utf-8") do |f|
53
+ f.write xml_file
36
54
  f.path
37
55
  end
56
+ end
38
57
  FileUtils.rm_rf dir
39
- ::Metanorma::Output::XslfoPdf.new.convert(input_filename,
40
- output_filename || "#{filename}.#{@suffix}",
41
- File.join(@libdir, pdf_stylesheet(docxml)),
42
- pdf_options(docxml))
43
- end
44
58
 
45
- def xref_parse(node, out)
46
- target = /#/.match(node["target"]) ? node["target"].sub(/#/, ".pdf#") :
47
- "##{node["target"]}"
48
- out.a(**{ "href": target }) { |l| l << get_linkend(node) }
59
+ [input_filename, docxml, filename]
49
60
  end
50
61
  end
51
62
  end