isodoc 1.0.27 → 1.1.2

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +4 -8
  3. data/.github/workflows/ubuntu.yml +18 -16
  4. data/.github/workflows/windows.yml +4 -8
  5. data/Rakefile +3 -1
  6. data/isodoc.gemspec +2 -2
  7. data/lib/isodoc.rb +2 -0
  8. data/lib/isodoc/base_style/metanorma_word.scss +0 -1
  9. data/lib/isodoc/base_style/reset.scss +3 -3
  10. data/lib/isodoc/common.rb +0 -4
  11. data/lib/isodoc/convert.rb +121 -58
  12. data/lib/isodoc/function/blocks.rb +42 -53
  13. data/lib/isodoc/function/blocks_example_note.rb +108 -0
  14. data/lib/isodoc/function/cleanup.rb +8 -4
  15. data/lib/isodoc/function/i18n.rb +1 -0
  16. data/lib/isodoc/function/inline.rb +70 -90
  17. data/lib/isodoc/function/inline_simple.rb +72 -0
  18. data/lib/isodoc/function/lists.rb +12 -6
  19. data/lib/isodoc/function/references.rb +33 -38
  20. data/lib/isodoc/function/reqt.rb +14 -5
  21. data/lib/isodoc/function/section.rb +8 -11
  22. data/lib/isodoc/function/table.rb +4 -4
  23. data/lib/isodoc/function/terms.rb +3 -3
  24. data/lib/isodoc/function/to_word_html.rb +21 -13
  25. data/lib/isodoc/function/utils.rb +57 -50
  26. data/lib/isodoc/gem_tasks.rb +104 -0
  27. data/lib/isodoc/headlesshtml_convert.rb +7 -6
  28. data/lib/isodoc/html_convert.rb +2 -1
  29. data/lib/isodoc/html_function/footnotes.rb +1 -1
  30. data/lib/isodoc/html_function/html.rb +13 -1
  31. data/lib/isodoc/html_function/postprocess.rb +4 -4
  32. data/lib/isodoc/metadata.rb +74 -62
  33. data/lib/isodoc/pdf_convert.rb +8 -6
  34. data/lib/isodoc/presentation_xml_convert.rb +29 -0
  35. data/lib/isodoc/sassc_importer.rb +11 -0
  36. data/lib/isodoc/version.rb +1 -1
  37. data/lib/isodoc/word_convert.rb +2 -1
  38. data/lib/isodoc/word_function/body.rb +14 -48
  39. data/lib/isodoc/word_function/footnotes.rb +1 -1
  40. data/lib/isodoc/word_function/inline.rb +75 -0
  41. data/lib/isodoc/word_function/postprocess.rb +1 -0
  42. data/lib/isodoc/word_function/table.rb +3 -3
  43. data/lib/isodoc/xref.rb +59 -0
  44. data/lib/isodoc/{function → xref}/xref_anchor.rb +10 -21
  45. data/lib/isodoc/xref/xref_counter.rb +74 -0
  46. data/lib/isodoc/{function → xref}/xref_gen.rb +9 -22
  47. data/lib/isodoc/{function → xref}/xref_gen_seq.rb +41 -32
  48. data/lib/isodoc/{function → xref}/xref_sect_gen.rb +33 -23
  49. data/lib/isodoc/xslfo_convert.rb +16 -4
  50. data/spec/assets/{html.css → html.scss} +0 -0
  51. data/spec/assets/i18n.yaml +4 -1
  52. data/spec/assets/odf.emf +0 -0
  53. data/spec/assets/odf.svg +4 -0
  54. data/spec/assets/odf1.svg +4 -0
  55. data/spec/isodoc/blocks_spec.rb +219 -47
  56. data/spec/isodoc/cleanup_spec.rb +135 -6
  57. data/spec/isodoc/footnotes_spec.rb +22 -7
  58. data/spec/isodoc/inline_spec.rb +262 -2
  59. data/spec/isodoc/lists_spec.rb +8 -8
  60. data/spec/isodoc/metadata_spec.rb +110 -3
  61. data/spec/isodoc/postproc_spec.rb +1321 -1351
  62. data/spec/isodoc/presentation_xml_spec.rb +20 -0
  63. data/spec/isodoc/ref_spec.rb +119 -50
  64. data/spec/isodoc/section_spec.rb +84 -18
  65. data/spec/isodoc/table_spec.rb +6 -6
  66. data/spec/isodoc/terms_spec.rb +7 -7
  67. data/spec/isodoc/xref_spec.rb +165 -45
  68. metadata +36 -27
  69. data/lib/isodoc/function/blocks_example.rb +0 -53
  70. data/lib/isodoc/function/xref_counter.rb +0 -50
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68d6f17f0d5291c6c067bfc6a3a476885b80f128bdc9c4e3e3d8356c6af30482
4
- data.tar.gz: 2710c48aa2fb9eeee44b586107b07884d52802a53fec81d69c0f3fb68fa988ed
3
+ metadata.gz: 5bd9d095a9d498797d6c48b1465b878f5587107e47f09a76a4148ba3a9618db0
4
+ data.tar.gz: a0825c515977f0ae8fe7047848480d2e2131be9b3baed8c803ae17aedf6270cd
5
5
  SHA512:
6
- metadata.gz: 1c38cb43027aa1a056d465660449a4a58e1a5b78474a5f0184fca4164f2af2480720329e5a7181fcc1731151ef15db71019aa9fc34175b779de517006bf85fa6
7
- data.tar.gz: '09503b88edfb1db0b3def003bca81c356b40790014953a9bc08de680af8db75222ded714f43a1f6820ec30dbaa2e3f83ac2a5e386f3c757f0d639f086e0b4b2c'
6
+ metadata.gz: 23b189ba917e52f1822ad80f096b8abb3fb3eca22e06f860fc300c8f3155492da9a7ef1817a43f6674657456885086ba73c5909d0106cdbbd9efe2392269e408
7
+ data.tar.gz: 2f72ce5902ef2a944f5b49d657e71e0afde82b1d94a2c6e9661d004b54810f7109faa98f2272b651a917da1fbf19e39bd027186e57597b2ae447e8551886e390
@@ -29,18 +29,14 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
32
+ - name: Install Inkscape
33
+ run: |
34
+ brew cask install inkscape
35
+ inkscape --version
33
36
  - name: Update gems
34
37
  run: |
35
38
  sudo gem install bundler --force
36
39
  bundle install --jobs 4 --retry 3
37
- - name: Use Node
38
- uses: actions/setup-node@v1
39
- with:
40
- node-version: '12'
41
- - name: Install Puppeteer
42
- run: |
43
- npm install -g puppeteer@3.0.1
44
40
  - name: Run specs
45
41
  run: |
46
42
  bundle exec rake
@@ -5,6 +5,8 @@ name: ubuntu
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
+ tags:
9
+ - '*'
8
10
  pull_request:
9
11
  paths-ignore:
10
12
  - .github/workflows/macos.yml
@@ -29,32 +31,32 @@ jobs:
29
31
  uses: actions/setup-ruby@v1
30
32
  with:
31
33
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
34
+ - name: Install Inkscape
35
+ run: |
36
+ sudo add-apt-repository ppa:inkscape.dev/stable
37
+ sudo apt update
38
+ sudo apt install inkscape
39
+ inkscape --version
33
40
  - name: Update gems
34
41
  run: |
35
42
  gem install bundler
36
43
  bundle install --jobs 4 --retry 3
37
- - name: Use Node
38
- uses: actions/setup-node@v1
39
- with:
40
- node-version: '12'
41
- - name: Install Puppeteer
42
- run: |
43
- sudo apt-get update
44
- sudo apt-get install libgbm1
45
- npm install -g puppeteer@3.0.1
46
44
  - name: Run specs
47
45
  run: |
48
46
  bundle exec rake
49
- - name: Trigger dependent repositories
50
- if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
47
+ - name: Trigger repositories
48
+ if: matrix.ruby == '2.6'
51
49
  env:
52
- GH_USERNAME: ${{ secrets.PAT_USERNAME }}
53
- GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
50
+ GH_USERNAME: metanorma-ci
51
+ GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
54
52
  run: |
55
53
  curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
56
54
  [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
57
- for repo in $DEPENDENT_REPOS
55
+ CLIENT_PAYLOAD=$(cat <<EOF
56
+ "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
57
+ EOF
58
+ )
59
+ for repo in $REPOS
58
60
  do
59
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY
61
+ sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
60
62
  done
@@ -29,20 +29,16 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
32
+ - name: Install Inkscape
33
+ run: |
34
+ choco install --no-progress -y inkscape
35
+ inkscape --version
33
36
  - name: Update gems
34
37
  shell: pwsh
35
38
  run: |
36
39
  gem install bundler
37
40
  bundle config --local path vendor/bundle
38
41
  bundle install --jobs 4 --retry 3
39
- - name: Use Node
40
- uses: actions/setup-node@v1
41
- with:
42
- node-version: '12'
43
- - name: Install Puppeteer
44
- run: |
45
- npm install -g puppeteer@3.0.1
46
42
  - name: Run specs
47
43
  run: |
48
44
  bundle exec rake
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require 'isodoc/gem_tasks'
3
4
 
5
+ IsoDoc::GemTasks.install
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task default: :spec
8
+ task default: :spec
@@ -36,11 +36,11 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "html2doc", "~> 1.0.0"
37
37
  spec.add_dependency "liquid"
38
38
  spec.add_dependency "roman-numerals"
39
- spec.add_dependency "sassc", "~> 2.2.1"
40
- spec.add_dependency "metanorma", "~> 1.0.0"
39
+ spec.add_dependency "metanorma", "~> 1.1.0"
41
40
  spec.add_dependency "rake", "~> 12.0"
42
41
 
43
42
  spec.add_development_dependency "byebug", "~> 9.1"
43
+ spec.add_development_dependency "sassc", "~> 2.4.0"
44
44
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
45
45
  spec.add_development_dependency "guard", "~> 2.14"
46
46
  spec.add_development_dependency "guard-rspec", "~> 4.7"
@@ -21,6 +21,8 @@ require "isodoc/word_convert"
21
21
  require "isodoc/pdf_convert"
22
22
  require "isodoc/xslfo_convert"
23
23
  require "isodoc/headlesshtml_convert"
24
+ require "isodoc/presentation_xml_convert"
25
+ require "isodoc/xref"
24
26
 
25
27
  module IsoDoc
26
28
 
@@ -28,4 +28,3 @@ br.section
28
28
  br.pagebreak
29
29
  {page-break-before:always;
30
30
  mso-special-character:line-break;}
31
-
@@ -49,9 +49,9 @@ time, mark, audio, video {
49
49
  }
50
50
 
51
51
  html, body, div, span, applet, object, iframe,
52
- p, blockquote,
53
- a, abbr, acronym, address, big, cite,
54
- del, dfn, em, img, ins, q, s,
52
+ p, blockquote,
53
+ a, abbr, acronym, address, big, cite,
54
+ del, dfn, em, img, ins, q, s,
55
55
  small, strike, strong, sub, sup, var,
56
56
  b, u, i, center,
57
57
  dl, dt, dd, ol, ul, li,
@@ -9,8 +9,6 @@ require_relative "./function/table"
9
9
  require_relative "./function/terms"
10
10
  require_relative "./function/to_word_html"
11
11
  require_relative "./function/utils"
12
- require_relative "./function/xref_gen"
13
- require_relative "./function/xref_sect_gen"
14
12
  require_relative "./function/reqt"
15
13
  require_relative "./class_utils"
16
14
 
@@ -27,8 +25,6 @@ module IsoDoc
27
25
  include Function::Terms
28
26
  include Function::ToWordHtml
29
27
  include Function::Utils
30
- include Function::XrefGen
31
- include Function::XrefSectGen
32
28
 
33
29
  extend ::IsoDoc::ClassUtils
34
30
  end
@@ -1,7 +1,8 @@
1
- require "isodoc/common"
2
- require "sassc"
3
- require "fileutils"
4
- require "tempfile"
1
+ # frozen_string_literal: true
2
+
3
+ require 'isodoc/common'
4
+ require 'fileutils'
5
+ require 'tempfile'
5
6
 
6
7
  module IsoDoc
7
8
  class Convert < ::IsoDoc::Common
@@ -27,15 +28,25 @@ module IsoDoc
27
28
  # scripts_pdf: Scripts file for PDF
28
29
  # datauriimage: Encode images in HTML output as data URIs
29
30
  def initialize(options)
30
- @libdir = File.dirname(__FILE__) unless @libdir
31
- options.merge!(default_fonts(options)) { |_, old, new| old || new }.
32
- merge!(default_file_locations(options)) { |_, old, new| old || new }
31
+ @libdir ||= File.dirname(__FILE__)
32
+ options.merge!(default_fonts(options)) do |_, old, new|
33
+ old || new
34
+ end
35
+ .merge!(default_file_locations(options)) do |_, old, new|
36
+ old || new
37
+ end
33
38
  @options = options
34
39
  @files_to_delete = []
35
40
  @tempfile_cache = []
36
- @htmlstylesheet_name = options[:htmlstylesheet]
37
- @wordstylesheet_name = options[:wordstylesheet]
38
- @standardstylesheet_name = options[:standardstylesheet]
41
+ @htmlstylesheet_name = precompiled_style_or_original(
42
+ options[:htmlstylesheet]
43
+ )
44
+ @wordstylesheet_name = precompiled_style_or_original(
45
+ options[:wordstylesheet]
46
+ )
47
+ @standardstylesheet_name = precompiled_style_or_original(
48
+ options[:standardstylesheet]
49
+ )
39
50
  @header = options[:header]
40
51
  @htmlcoverpage = options[:htmlcoverpage]
41
52
  @wordcoverpage = options[:wordcoverpage]
@@ -48,12 +59,11 @@ module IsoDoc
48
59
  @olstyle = options[:olstyle]
49
60
  @datauriimage = options[:datauriimage]
50
61
  @suppressheadingnumbers = options[:suppressheadingnumbers]
51
- @break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
52
- @termdomain = ""
62
+ @break_up_urls_in_tables = options[:break_up_urls_in_tables] == 'true'
63
+ @termdomain = ''
53
64
  @termexample = false
54
65
  @note = false
55
66
  @sourcecode = false
56
- @anchors = {}
57
67
  @footnotes = []
58
68
  @comments = []
59
69
  @in_footnote = false
@@ -62,40 +72,57 @@ module IsoDoc
62
72
  @in_figure = false
63
73
  @seen_footnote = Set.new
64
74
  @c = HTMLEntities.new
65
- @openmathdelim = "`"
66
- @closemathdelim = "`"
67
- @lang = "en"
68
- @script = "Latn"
75
+ @openmathdelim = '`'
76
+ @closemathdelim = '`'
77
+ @lang = 'en'
78
+ @script = 'Latn'
69
79
  @maxwidth = 1200
70
80
  @maxheight = 800
71
81
  @wordToClevels = options[:doctoclevels].to_i
72
- @wordToClevels = 2 if @wordToClevels == 0
82
+ @wordToClevels = 2 if @wordToClevels.zero?
73
83
  @htmlToClevels = options[:htmltoclevels].to_i
74
- @htmlToClevels = 2 if @htmlToClevels == 0
75
- @bookmarks_allocated = {"X" => true}
84
+ @htmlToClevels = 2 if @htmlToClevels.zero?
85
+ @bookmarks_allocated = { 'X' => true }
76
86
  @fn_bookmarks = {}
77
87
  end
78
88
 
89
+ # Check if already compiled version(.css) exists,
90
+ # if not, return original scss file. During release
91
+ # we compile scss into css files in order to not depend on scss
92
+ def precompiled_style_or_original(stylesheet_path)
93
+ # Already have compiled stylesheet, use it
94
+ return stylesheet_path if stylesheet_path.nil? ||
95
+ File.extname(stylesheet_path) == '.css'
96
+
97
+ basename = File.basename(stylesheet_path, '.*')
98
+ compiled_path = File.join(File.dirname(stylesheet_path),
99
+ "#{basename}.css")
100
+ return stylesheet_path unless File.file?(compiled_path)
101
+
102
+ compiled_path
103
+ end
104
+
79
105
  # run this after @meta is populated
80
106
  def populate_css
81
- @htmlstylesheet = generate_css(@htmlstylesheet_name, true, extract_fonts(options))
82
- @wordstylesheet = generate_css(@wordstylesheet_name, false, extract_fonts(options))
83
- @standardstylesheet = generate_css(@standardstylesheet_name, false, extract_fonts(options))
107
+ @htmlstylesheet = generate_css(@htmlstylesheet_name, true)
108
+ @wordstylesheet = generate_css(@wordstylesheet_name, false)
109
+ @standardstylesheet = generate_css(@standardstylesheet_name, false)
84
110
  end
85
111
 
86
112
  def tmpimagedir_suffix
87
- "_images"
113
+ '_images'
88
114
  end
89
115
 
90
116
  def default_fonts(_options)
91
117
  {
92
- bodyfont: "Arial",
93
- headerfont: "Arial",
94
- monospacefont: "Courier",
118
+ bodyfont: 'Arial',
119
+ headerfont: 'Arial',
120
+ monospacefont: 'Courier'
95
121
  }
96
122
  end
97
123
 
98
- # none for this parent gem, but will be populated in child gems which have access to stylesheets &c; e.g.
124
+ # none for this parent gem, but will be populated in child
125
+ # gems which have access to stylesheets &c; e.g.
99
126
  # {
100
127
  # htmlstylesheet: html_doc_path("htmlstyle.scss"),
101
128
  # htmlcoverpage: html_doc_path("html_rsd_titlepage.html"),
@@ -113,41 +140,62 @@ module IsoDoc
113
140
  {}
114
141
  end
115
142
 
116
- # extract fonts for use in generate_css
117
- def extract_fonts(options)
118
- b = options[:bodyfont] || "Arial"
119
- h = options[:headerfont] || "Arial"
120
- m = options[:monospacefont] || "Courier"
143
+ def fonts_options
144
+ {
145
+ 'bodyfont' => options[:bodyfont] || 'Arial',
146
+ 'headerfont' => options[:headerfont] || 'Arial',
147
+ 'monospacefont' => options[:monospacefont] || 'Courier'
148
+ }
149
+ end
150
+
151
+ def scss_fontheader
152
+ b = options[:bodyfont] || 'Arial'
153
+ h = options[:headerfont] || 'Arial'
154
+ m = options[:monospacefont] || 'Courier'
121
155
  "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"
122
156
  end
123
157
 
124
158
  def html_doc_path(file)
125
- File.join(@libdir, File.join("html", file))
159
+ File.join(@libdir, File.join('html', file))
126
160
  end
127
161
 
128
- def generate_css(filename, stripwordcss, fontheader)
129
- return nil unless filename
130
- stylesheet = File.read(filename, encoding: "UTF-8")
162
+ def convert_scss(filename, stylesheet)
163
+ require 'sassc'
164
+ require 'isodoc/sassc_importer'
165
+
166
+ [File.join(Gem.loaded_specs['isodoc'].full_gem_path,
167
+ 'lib', 'isodoc'),
168
+ File.dirname(filename)].each do |name|
169
+ SassC.load_paths << name
170
+ end
171
+ SassC::Engine.new(scss_fontheader + stylesheet, syntax: :scss,
172
+ importer: SasscImporter)
173
+ .render
174
+ end
175
+
176
+ def generate_css(filename, stripwordcss)
177
+ return nil if filename.nil?
178
+
179
+ stylesheet = File.read(filename, encoding: 'UTF-8')
131
180
  stylesheet = populate_template(stylesheet, :word)
132
- stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, "\\1") if stripwordcss
133
- SassC.load_paths << File.join(Gem.loaded_specs['isodoc'].full_gem_path,
134
- "lib", "isodoc")
135
- SassC.load_paths << File.dirname(filename)
136
- engine = SassC::Engine.new(fontheader + stylesheet, syntax: :scss)
137
- Tempfile.open([File.basename(filename, ".*"), "css"],
138
- :encoding => "utf-8") do |f|
139
- f.write(engine.render)
181
+ stylesheet.gsub!(/(\s|\{)mso-[^:]+:[^;]+;/m, '\\1') if stripwordcss
182
+ if File.extname(filename) == '.scss'
183
+ stylesheet = convert_scss(filename, stylesheet)
184
+ end
185
+ Tempfile.open([File.basename(filename, '.*'), 'css'],
186
+ encoding: 'utf-8') do |f|
187
+ f.write(stylesheet)
140
188
  f
141
189
  end
142
190
  end
143
191
 
144
192
  def convert1(docxml, filename, dir)
145
- anchor_names docxml
193
+ @xrefs.parse docxml
146
194
  noko do |xml|
147
- xml.html **{ lang: "#{@lang}" } do |html|
148
- html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
195
+ xml.html **{ lang: @lang.to_s } do |html|
196
+ html.parent.add_namespace('epub', 'http://www.idpf.org/2007/ops')
149
197
  info docxml, nil
150
- populate_css()
198
+ populate_css
151
199
  html.head { |head| define_head head, filename, dir }
152
200
  make_body(html, docxml)
153
201
  end
@@ -158,25 +206,40 @@ module IsoDoc
158
206
  @meta = Metadata.new(lang, script, labels)
159
207
  end
160
208
 
161
- def convert_init(file, filename, debug)
209
+ def xref_init(lang, script, klass, labels, options)
210
+ @xrefs = Xref.new(lang, script, klass, labels, options)
211
+ end
212
+
213
+ def convert_init(file, input_filename, debug)
162
214
  docxml = Nokogiri::XML(file)
163
- filename, dir = init_file(filename, debug)
164
- docxml.root.default_namespace = ""
165
- lang = docxml&.at(ns("//bibdata/language"))&.text || @lang
166
- script = docxml&.at(ns("//bibdata/script"))&.text || @script
215
+ filename, dir = init_file(input_filename, debug)
216
+ docxml.root.default_namespace = ''
217
+ lang = docxml&.at(ns('//bibdata/language'))&.text || @lang
218
+ script = docxml&.at(ns('//bibdata/script'))&.text || @script
167
219
  i18n_init(lang, script)
168
220
  metadata_init(lang, script, @labels)
221
+ @meta.fonts_options = fonts_options
222
+ xref_init(lang, script, self, @labels, {})
169
223
  [docxml, filename, dir]
170
224
  end
171
225
 
172
- def convert(filename, file = nil, debug = false)
173
- file = File.read(filename, encoding: "utf-8") if file.nil?
226
+ def convert(input_filename,
227
+ file = nil,
228
+ debug = false,
229
+ output_filename = nil)
230
+ file = File.read(input_filename, encoding: 'utf-8') if file.nil?
174
231
  @openmathdelim, @closemathdelim = extract_delims(file)
175
- docxml, filename, dir = convert_init(file, filename, debug)
232
+ docxml, filename, dir = convert_init(file, input_filename, debug)
176
233
  result = convert1(docxml, filename, dir)
177
234
  return result if debug
178
- postprocess(result, filename, dir)
235
+ output_filename ||= "#{filename}.#{@suffix}"
236
+ postprocess(result, output_filename, dir)
179
237
  FileUtils.rm_rf dir
180
238
  end
239
+
240
+ def middle_clause
241
+ "//clause[parent::sections][not(xmlns:title = 'Scope')]"\
242
+ '[not(descendant::terms)]'
243
+ end
181
244
  end
182
245
  end