omml2mathml 0.0.2 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9c27bbca78f13e60634b106be7fca722cdbba2ed461ade5744dec17b3be89cb
4
- data.tar.gz: 87cad237febb6fe44de1963c04938a4e5b5a9dd5c38d39b2493e6f2987edf2c0
3
+ metadata.gz: 32b7152d111102b734e6ee1fe4c41cbb2379efc408852cdb1ed3966b9f6c62db
4
+ data.tar.gz: 96eb1d2c611adb9b932289593e3ef2fa94a51c6cd75c0e0ed44f0d6e1adaada4
5
5
  SHA512:
6
- metadata.gz: c33a44c6b628a7e8531dfce6ec45ce9f14cb6241d1cabd014b13757cc22e2f841a49c4f7ec66ecff3b0d1138a0405c2d6d6fa561efb48f713626f95016d5690c
7
- data.tar.gz: dc15a0d20ef2e40846e8545159716c1f46d575145fa8d4e36876611770a60b6897b4be022f16a18bcb55b228a4640275d00c00c45e3e86ba9b4bc99794878279
6
+ metadata.gz: 25a79cba1de8666521f3366c8f0f9b53d04df71518abc7fd07f73ae74979a0612cf8a3ea9d8bfa3e171afbf410d87cabec184c233fd015430117125a1ac5478d
7
+ data.tar.gz: 6b2289d3d6ee2969c5388a26bbdb35df9b4852939e9514bda2d4af71003eb14868d465a6b19d0853aab6c8c16e15e733d178d3a425671e182092de28ceaf1d80
@@ -0,0 +1,38 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: macos
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/ubuntu.yml
11
+ - .github/workflows/windows.yml
12
+
13
+ jobs:
14
+ test-macos:
15
+ name: Test on Ruby ${{ matrix.ruby }} macOS
16
+ runs-on: macos-latest
17
+ continue-on-error: ${{ matrix.experimental }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
26
+ steps:
27
+ - uses: actions/checkout@master
28
+ - name: Use Ruby
29
+ uses: actions/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ - name: Update gems
33
+ run: |
34
+ sudo gem install bundler --force
35
+ bundle install --jobs 4 --retry 3
36
+ - name: Run specs
37
+ run: |
38
+ bundle exec rake
@@ -0,0 +1,56 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: ubuntu
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ tags:
9
+ - '*'
10
+ pull_request:
11
+ paths-ignore:
12
+ - .github/workflows/macos.yml
13
+ - .github/workflows/windows.yml
14
+
15
+ jobs:
16
+ test-linux:
17
+ name: Test on Ruby ${{ matrix.ruby }} Ubuntu
18
+ runs-on: ubuntu-latest
19
+ continue-on-error: ${{ matrix.experimental }}
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ ruby: [ '2.6', '2.5', '2.4' ]
24
+ experimental: [false]
25
+ include:
26
+ - ruby: '2.7'
27
+ experimental: true
28
+ steps:
29
+ - uses: actions/checkout@master
30
+ - name: Use Ruby
31
+ uses: actions/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ - name: Update gems
35
+ run: |
36
+ gem install bundler
37
+ bundle install --jobs 4 --retry 3
38
+ - name: Run specs
39
+ run: |
40
+ bundle exec rake
41
+ - name: Trigger repositories
42
+ if: matrix.ruby == '2.6'
43
+ env:
44
+ GH_USERNAME: metanorma-ci
45
+ GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
46
+ run: |
47
+ curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
48
+ [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
49
+ CLIENT_PAYLOAD=$(cat <<EOF
50
+ "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
51
+ EOF
52
+ )
53
+ for repo in $REPOS
54
+ do
55
+ sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
56
+ done
@@ -0,0 +1,40 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: windows
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+ paths-ignore:
10
+ - .github/workflows/macos.yml
11
+ - .github/workflows/ubuntu.yml
12
+
13
+ jobs:
14
+ test-windows:
15
+ name: Test on Ruby ${{ matrix.ruby }} Windows
16
+ runs-on: windows-latest
17
+ continue-on-error: ${{ matrix.experimental }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
26
+ steps:
27
+ - uses: actions/checkout@master
28
+ - name: Use Ruby
29
+ uses: actions/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ - name: Update gems
33
+ shell: pwsh
34
+ run: |
35
+ gem install bundler
36
+ bundle config --local path vendor/bundle
37
+ bundle install --jobs 4 --retry 3
38
+ - name: Run specs
39
+ run: |
40
+ bundle exec rake
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ Enabled: true
3
+ config_file: .rubocop.yml
@@ -3,13 +3,8 @@
3
3
  # All project-specific additions and overrides should be specified in this file.
4
4
 
5
5
  inherit_from:
6
- # Thoughtbot's style guide from: https://github.com/thoughtbot/guides
7
- - ".rubocop.tb.yml"
8
- # Overrides from Ribose
9
- - ".rubocop.ribose.yml"
6
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
10
7
  AllCops:
11
- DisplayCopNames: false
12
- StyleGuideCopsOnly: false
13
- TargetRubyVersion: 2.4
8
+ TargetRubyVersion: 2.3
14
9
  Rails:
15
10
  Enabled: true
@@ -1,23 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omml2mathml (0.0.2)
5
- nokogiri
6
- ruby-xslt
4
+ omml2mathml (0.0.7)
5
+ nokogiri (>= 1.10.4)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- ast (2.4.0)
10
+ ast (2.4.1)
12
11
  byebug (9.1.0)
13
- coderay (1.1.2)
14
- diff-lcs (1.3)
15
- docile (1.3.1)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.4.4)
14
+ docile (1.3.2)
16
15
  equivalent-xml (0.6.0)
17
16
  nokogiri (>= 1.4.3)
18
- ffi (1.9.25)
17
+ ffi (1.13.1)
19
18
  formatador (0.2.5)
20
- guard (2.14.2)
19
+ guard (2.16.2)
21
20
  formatador (>= 0.2.4)
22
21
  listen (>= 2.7, < 4.0)
23
22
  lumberjack (>= 1.0.12, < 2.0)
@@ -31,74 +30,67 @@ GEM
31
30
  guard (~> 2.1)
32
31
  guard-compat (~> 1.1)
33
32
  rspec (>= 2.99.0, < 4.0)
34
- jaro_winkler (1.5.1)
35
- json (2.1.0)
36
- listen (3.1.5)
37
- rb-fsevent (~> 0.9, >= 0.9.4)
38
- rb-inotify (~> 0.9, >= 0.9.7)
39
- ruby_dep (~> 1.2)
40
- lumberjack (1.0.13)
41
- method_source (0.9.0)
42
- mini_portile2 (2.3.0)
33
+ listen (3.2.1)
34
+ rb-fsevent (~> 0.10, >= 0.10.3)
35
+ rb-inotify (~> 0.9, >= 0.9.10)
36
+ lumberjack (1.2.6)
37
+ method_source (1.0.0)
38
+ mini_portile2 (2.4.0)
43
39
  nenv (0.3.0)
44
- nokogiri (1.8.4)
45
- mini_portile2 (~> 2.3.0)
46
- notiffany (0.1.1)
40
+ nokogiri (1.10.10)
41
+ mini_portile2 (~> 2.4.0)
42
+ notiffany (0.1.3)
47
43
  nenv (~> 0.1)
48
44
  shellany (~> 0.0)
49
- parallel (1.12.1)
50
- parser (2.5.1.2)
51
- ast (~> 2.4.0)
45
+ parallel (1.19.2)
46
+ parser (2.7.1.4)
47
+ ast (~> 2.4.1)
52
48
  powerpack (0.1.2)
53
- pry (0.11.3)
54
- coderay (~> 1.1.0)
55
- method_source (~> 0.9.0)
49
+ pry (0.13.1)
50
+ coderay (~> 1.1)
51
+ method_source (~> 1.0)
56
52
  rainbow (3.0.0)
57
- rake (12.3.1)
58
- rb-fsevent (0.10.3)
59
- rb-inotify (0.9.10)
60
- ffi (>= 0.5.0, < 2)
61
- rspec (3.7.0)
62
- rspec-core (~> 3.7.0)
63
- rspec-expectations (~> 3.7.0)
64
- rspec-mocks (~> 3.7.0)
65
- rspec-core (3.7.1)
66
- rspec-support (~> 3.7.0)
67
- rspec-expectations (3.7.0)
53
+ rake (12.3.3)
54
+ rb-fsevent (0.10.4)
55
+ rb-inotify (0.10.1)
56
+ ffi (~> 1.0)
57
+ rspec (3.9.0)
58
+ rspec-core (~> 3.9.0)
59
+ rspec-expectations (~> 3.9.0)
60
+ rspec-mocks (~> 3.9.0)
61
+ rspec-core (3.9.2)
62
+ rspec-support (~> 3.9.3)
63
+ rspec-expectations (3.9.2)
68
64
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.7.0)
65
+ rspec-support (~> 3.9.0)
70
66
  rspec-match_fuzzy (0.1.3)
71
67
  rspec (>= 3.2)
72
- rspec-mocks (3.7.0)
68
+ rspec-mocks (3.9.1)
73
69
  diff-lcs (>= 1.2.0, < 2.0)
74
- rspec-support (~> 3.7.0)
75
- rspec-support (3.7.1)
76
- rubocop (0.58.1)
77
- jaro_winkler (~> 1.5.1)
70
+ rspec-support (~> 3.9.0)
71
+ rspec-support (3.9.3)
72
+ rubocop (0.54.0)
78
73
  parallel (~> 1.10)
79
- parser (>= 2.5, != 2.5.1.1)
74
+ parser (>= 2.5)
80
75
  powerpack (~> 0.1)
81
76
  rainbow (>= 2.2.2, < 4.0)
82
77
  ruby-progressbar (~> 1.7)
83
78
  unicode-display_width (~> 1.0, >= 1.0.1)
84
- ruby-progressbar (1.9.0)
85
- ruby-xslt (0.9.10)
86
- ruby_dep (1.5.0)
79
+ ruby-progressbar (1.10.1)
87
80
  shellany (0.0.1)
88
- simplecov (0.16.1)
81
+ simplecov (0.18.5)
89
82
  docile (~> 1.1)
90
- json (>= 1.8, < 3)
91
- simplecov-html (~> 0.10.0)
92
- simplecov-html (0.10.2)
93
- thor (0.20.0)
83
+ simplecov-html (~> 0.11)
84
+ simplecov-html (0.12.2)
85
+ thor (1.0.1)
94
86
  timecop (0.9.1)
95
- unicode-display_width (1.4.0)
87
+ unicode-display_width (1.7.0)
96
88
 
97
89
  PLATFORMS
98
90
  ruby
99
91
 
100
92
  DEPENDENCIES
101
- bundler (~> 1.15)
93
+ bundler
102
94
  byebug (~> 9.1)
103
95
  equivalent-xml (~> 0.6)
104
96
  guard (~> 2.14)
@@ -107,9 +99,9 @@ DEPENDENCIES
107
99
  rake (~> 12.0)
108
100
  rspec
109
101
  rspec-match_fuzzy
110
- rubocop (~> 0.50)
102
+ rubocop (= 0.54.0)
111
103
  simplecov (~> 0.15)
112
104
  timecop (~> 0.9)
113
105
 
114
106
  BUNDLED WITH
115
- 1.16.2
107
+ 2.1.4
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,8 +1,12 @@
1
1
  = omml2mathml
2
2
 
3
3
  image:https://img.shields.io/gem/v/omml2mathml.svg["Gem Version", link="https://rubygems.org/gems/omml2mathml"]
4
- image:https://img.shields.io/travis/riboseinc/omml2mathml/master.svg["Build Status", link="https://travis-ci.org/riboseinc/omml2mathml"]
5
- image:https://codeclimate.com/github/riboseinc/omml2mathml/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/omml2mathml"]
4
+ image:https://github.com/metanorma/omml2mathml/workflows/ubuntu/badge.svg["Ubuntu Build Status", link="https://github.com/metanorma/omml2mathml/actions?query=workflow%3Aubuntu"]
5
+ image:https://github.com/metanorma/omml2mathml/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/omml2mathml/actions?query=workflow%3Amacos"]
6
+ image:https://github.com/metanorma/omml2mathml/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/omml2mathml/actions?query=workflow%3Awindows"]
7
+ image:https://codeclimate.com/github/metanorma/omml2mathml/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/omml2mathml"]
8
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/omml2mathml.svg["Pull Requests", link="https://github.com/metanorma/omml2mathml/pulls"]
9
+ image:https://img.shields.io/github/commits-since/metanorma/omml2mathml/latest.svg["Commits since latest",link="https://github.com/metanorma/omml2mathml/releases"]
6
10
 
7
11
  Convert Office Math Markup to MathML
8
12
 
@@ -1,4 +1,3 @@
1
- require "xml/xslt"
2
1
  require "nokogiri"
3
2
 
4
3
  module Omml2Mathml
@@ -133,7 +132,7 @@ zeroWid
133
132
 
134
133
  @mathml = {}
135
134
  @tags.each do |t|
136
- @mathml["m_#{t.downcase}"] = "m:#{t}"
135
+ @mathml["m_#{t.downcase}"] = t
137
136
  end
138
137
 
139
138
  html = Nokogiri::HTML.parse(File.read(filename, encoding: "utf-8").
@@ -141,8 +140,7 @@ zeroWid
141
140
  gsub(/<\/m:/, "</m_").
142
141
  gsub(/<!\[if !msEquation\]>/,
143
142
  "<!--if !msEquation-->"))
144
- @xslt = XML::XSLT.new
145
- @xslt.xsl = File.join(File.dirname(__FILE__), "xhtml-mathml.xsl")
143
+ @xslt = Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), "xhtml-mathml.xsl"), "rb"))
146
144
  html.traverse do |n|
147
145
  if n.comment?
148
146
  if /^\[if gte msEquation 12\]>/.match n.text
@@ -157,29 +155,29 @@ zeroWid
157
155
  end
158
156
  end
159
157
  xml = Nokogiri::XML(html.to_xhtml)
158
+ ns = xml.root.add_namespace 'm', "http://schemas.microsoft.com/office/2004/12/omml"
160
159
  xml.traverse do |t|
161
160
  if t.element? && @mathml.has_key?(t.name)
162
161
  t.name = @mathml[t.name]
162
+ t.namespace = ns
163
163
  end
164
164
  end
165
165
  #xml.xpath("//xmlns:link | //xmlns:style | //*[@class = 'MsoToc1'] | //*[@class = 'MsoToc2'] |//*[@class = 'MsoToc3'] |//*[@class = 'MsoToc4'] |//*[@class = 'MsoToc5'] |//*[@class = 'MsoToc6'] |//*[@class = 'MsoToc7'] |//*[@class = 'MsoToc8'] |//*[@class = 'MsoToc9'] ").each { |x| x.remove }
166
- xml.xpath("//*").each do |x|
167
- if x.name == "m:oMath" || x.name == "m:oMathPara"
168
- @xslt.xml = x.to_xml.
169
- sub(/<m:(oMath|oMathPara)>/,
170
- "<m:\\1 xmlns:m='http://schemas.openxmlformats.org/officeDocument/2006/math'>")
171
- out = @xslt.serve
172
- mml = out.gsub(/<\?xml[^>]+>/, '').
173
- gsub(%r{<([^:/! >]+ xmlns="http://www.w3.org/1998/Math/MathML")},
174
- "<mml:\\1").
175
- gsub(%r{<([^:/!>]+)>}, "<mml:\\1>").
176
- gsub(%r{</([^:/!>]+)>}, "</mml:\\1>").
177
- gsub(%r{ xmlns="http://www.w3.org/1998/Math/MathML"}, "").
178
- gsub(%r{ xmlns:mml="http://www.w3.org/1998/Math/MathML"}, "").
179
- gsub(%r{ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"}, "").
180
- gsub(%r{ xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"}, "")
181
- x.replace("<mml:math>#{mml}</mml:math>")
182
- end
166
+ xml.xpath("//*[local-name()='oMath' or local-name()='oMathPara']").each do |x|
167
+ # prepare input: delete xmlns & change
168
+ input = Nokogiri::XML(x.to_xml.sub(/<m:(oMath|oMathPara)>/,
169
+ "<m:\\1 xmlns:m='http://schemas.openxmlformats.org/officeDocument/2006/math'>"))
170
+ out = @xslt.transform(input)
171
+ mml = out.to_xml.gsub(/<\?xml[^>]+>/, '').
172
+ gsub(%r{<([^:/! >]+ xmlns="http://www.w3.org/1998/Math/MathML")},
173
+ "<mml:\\1").
174
+ gsub(%r{<([^:/!>]+)>}, "<mml:\\1>").
175
+ gsub(%r{</([^:/!>]+)>}, "</mml:\\1>").
176
+ gsub(%r{ xmlns="http://www.w3.org/1998/Math/MathML"}, "").
177
+ gsub(%r{ xmlns:mml="http://www.w3.org/1998/Math/MathML"}, "").
178
+ gsub(%r{ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"}, "").
179
+ gsub(%r{ xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"}, "")
180
+ x.replace("<mml:math>#{mml}</mml:math>")
183
181
  end
184
182
  xml.to_s
185
183
  end
@@ -1,4 +1,4 @@
1
1
  module Omml2Mathml
2
- VERSION = "0.0.2".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
4
4