omml2mathml 0.0.11 → 0.0.12

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: 17247f910432e00811501068633cf13b08608f94b6f9fd292b4ba890850f6c96
4
- data.tar.gz: 7a9fca5bb1669e55a5f099652de29d316162498a3ec522aa93c3d48f1c684151
3
+ metadata.gz: a43e81376b59d50a063fee2bba22d0c8389be9815aa9c8b7ab8b5b7ba8db0ea4
4
+ data.tar.gz: 9a47fa58de802b21d87f9ce3209bacdb53f4a89a3fed825f86c2bc9840f44e75
5
5
  SHA512:
6
- metadata.gz: '069bc912bdc98d86feaddcdc355604b4c8279ca3290467961e196db8fe2c80b369586366ac58c19bafc71f1fe3f1ff206f223f350850df0609a09525211070eb'
7
- data.tar.gz: 38b3f348a5ca4f3078a4cf96b232346801ff224689b2bf78a4de00e9cd6b301dca6d02414cef18ce4787e8d8dd559f7a1d89190f39ec9c8f29851438fe8e45fa
6
+ metadata.gz: d2fad476725d69a5efac5468bc73e9b063374f7741a9599d33fc77e7e508f667f15928e134c17b30044bf792d523ee702cc4b62a79dae6dee2935da45254ecb8
7
+ data.tar.gz: 49e1f30ffeef309e521549fb5832d969de61e788274ff85ab95a2992d643278fb2c6ae03a525d4dca62fe33075d32245dbdede78d9f6f3cf8740077816d79a8d
@@ -10,23 +10,6 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@v2
24
- with:
25
- submodules: true
26
-
27
- - uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
- bundler-cache: true
31
-
32
- - run: bundle exec rake
13
+ uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -2,151 +2,157 @@ require "nokogiri"
2
2
 
3
3
  module Omml2Mathml
4
4
  module_function
5
+
5
6
  def convert(filename)
6
- @tags = %w{
7
- acc
8
- accPr
9
- aln
10
- alnScr
11
- argPr
12
- argSz
13
- bar
14
- barPr
15
- baseJc
16
- begChr
17
- borderBox
18
- borderBoxPr
19
- box
20
- boxPr
21
- brk
22
- brkBin
23
- brkBinSub
24
- cGp
25
- cGpRule
26
- chr
27
- count
28
- cSp
29
- ctrlPr
30
- d
31
- defJc
32
- deg
33
- degHide
34
- den
35
- diff
36
- dispDef
37
- dPr
38
- e
39
- endChr
40
- eqArr
41
- eqArrPr
42
- f
43
- fName
44
- fPr
45
- func
46
- funcPr
47
- groupChr
48
- groupChrPr
49
- grow
50
- hideBot
51
- hideLeft
52
- hideRight
53
- hideTop
54
- interSp
55
- intLim
56
- intraSp
57
- jc
58
- lim
59
- limLoc
60
- limLow
61
- limLowPr
62
- limUpp
63
- limUppPr
64
- lit
65
- lMargin
66
- m
67
- mathFont
68
- mathPr
69
- maxDist
70
- mc
71
- mcJc
72
- mcPr
73
- mcs
74
- mPr
75
- mr
76
- nary
77
- naryLim
78
- naryPr
79
- noBreak
80
- nor
81
- num
82
- objDist
83
- oMath
84
- oMathPara
85
- oMathParaPr
86
- opEmu
87
- phant
88
- phantPr
89
- plcHide
90
- pos
91
- postSp
92
- preSp
93
- r
94
- rad
95
- radPr
96
- rMargin
97
- rPr
98
- rSp
99
- rSpRule
100
- scr
101
- sepChr
102
- show
103
- shp
104
- smallFrac
105
- sPre
106
- sPrePr
107
- sSub
108
- sSubPr
109
- sSubSup
110
- sSubSupPr
111
- sSup
112
- sSupPr
113
- strikeBLTR
114
- strikeH
115
- strikeTLBR
116
- strikeV
117
- sty
118
- sub
119
- subHide
120
- sup
121
- supHide
122
- t
123
- transp
124
- type
125
- vertJc
126
- wrapIndent
127
- wrapRight
128
- zeroAsc
129
- zeroDesc
130
- zeroWid
131
- }
7
+ @tags = %w{
8
+ acc
9
+ accPr
10
+ aln
11
+ alnScr
12
+ argPr
13
+ argSz
14
+ bar
15
+ barPr
16
+ baseJc
17
+ begChr
18
+ borderBox
19
+ borderBoxPr
20
+ box
21
+ boxPr
22
+ brk
23
+ brkBin
24
+ brkBinSub
25
+ cGp
26
+ cGpRule
27
+ chr
28
+ count
29
+ cSp
30
+ ctrlPr
31
+ d
32
+ defJc
33
+ deg
34
+ degHide
35
+ den
36
+ diff
37
+ dispDef
38
+ dPr
39
+ e
40
+ endChr
41
+ eqArr
42
+ eqArrPr
43
+ f
44
+ fName
45
+ fPr
46
+ func
47
+ funcPr
48
+ groupChr
49
+ groupChrPr
50
+ grow
51
+ hideBot
52
+ hideLeft
53
+ hideRight
54
+ hideTop
55
+ interSp
56
+ intLim
57
+ intraSp
58
+ jc
59
+ lim
60
+ limLoc
61
+ limLow
62
+ limLowPr
63
+ limUpp
64
+ limUppPr
65
+ lit
66
+ lMargin
67
+ m
68
+ mathFont
69
+ mathPr
70
+ maxDist
71
+ mc
72
+ mcJc
73
+ mcPr
74
+ mcs
75
+ mPr
76
+ mr
77
+ nary
78
+ naryLim
79
+ naryPr
80
+ noBreak
81
+ nor
82
+ num
83
+ objDist
84
+ oMath
85
+ oMathPara
86
+ oMathParaPr
87
+ opEmu
88
+ phant
89
+ phantPr
90
+ plcHide
91
+ pos
92
+ postSp
93
+ preSp
94
+ r
95
+ rad
96
+ radPr
97
+ rMargin
98
+ rPr
99
+ rSp
100
+ rSpRule
101
+ scr
102
+ sepChr
103
+ show
104
+ shp
105
+ smallFrac
106
+ sPre
107
+ sPrePr
108
+ sSub
109
+ sSubPr
110
+ sSubSup
111
+ sSubSupPr
112
+ sSup
113
+ sSupPr
114
+ strikeBLTR
115
+ strikeH
116
+ strikeTLBR
117
+ strikeV
118
+ sty
119
+ sub
120
+ subHide
121
+ sup
122
+ supHide
123
+ t
124
+ transp
125
+ type
126
+ vertJc
127
+ wrapIndent
128
+ wrapRight
129
+ zeroAsc
130
+ zeroDesc
131
+ zeroWid
132
+ }
132
133
 
133
- @mathml = {}
134
- @tags.each do |t|
135
- @mathml["m_#{t.downcase}"] = t
136
- end
134
+ @mathml = {}
135
+ @tags.each do |t|
136
+ @mathml["m_#{t.downcase}"] = t
137
+ end
137
138
 
138
- html = Nokogiri::HTML.parse(File.read(filename, encoding: "utf-8").
139
- gsub(/\r/, "").gsub(/<m:/, "<m_").
140
- gsub(/<\/m:/, "</m_").
141
- gsub(/<!\[if !msEquation\]>/,
142
- "<!--if !msEquation-->"))
143
- @xslt = Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), "xhtml-mathml.xsl"), "rb"))
139
+ html = Nokogiri::HTML.parse(File.read(filename, encoding: "utf-8")
140
+ .gsub(/\r/, "").gsub(/<m:/, "<m_")
141
+ .gsub(/<\/m:/, "</m_")
142
+ .gsub(/<!\[endif\]>/, "<!--endif-->")
143
+ .gsub(/<!\[endif\]-->/, "<!--endif-- -->")
144
+ .gsub(/<!\[if !msEquation\]>/,
145
+ "<!--if !msEquation-->"))
146
+ @xslt = Nokogiri::XSLT(File.open(
147
+ File.join(File.dirname(__FILE__),
148
+ "xhtml-mathml.xsl"), "rb"
149
+ ))
144
150
  html.traverse do |n|
145
151
  if n.comment?
146
- if /^\[if gte msEquation 12\]>/.match n.text
147
- n.replace(n.text.sub(/\[if gte msEquation 12\]>/, "").
148
- sub(/<!\[endif\]/, ""))
149
- elsif /^if !msEquation/.match n.text
152
+ if /^\[if gte msEquation 12\]>/.match? n.text
153
+ n.replace(n.text.sub(/\[if gte msEquation 12\]>/, "")
154
+ .sub(/<!--endif-->/, ""))
155
+ elsif /^if !msEquation/.match? n.text
150
156
  n.next.remove
151
157
  n.remove
152
158
  else
@@ -155,28 +161,28 @@ zeroWid
155
161
  end
156
162
  end
157
163
  xml = Nokogiri::XML(html.to_xhtml)
158
- ns = xml.root.add_namespace 'm', "http://schemas.microsoft.com/office/2004/12/omml"
164
+ ns = xml.root.add_namespace "m", "http://schemas.microsoft.com/office/2004/12/omml"
159
165
  xml.traverse do |t|
160
166
  if t.element? && @mathml.has_key?(t.name)
161
167
  t.name = @mathml[t.name]
162
168
  t.namespace = ns
163
169
  end
164
170
  end
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 }
171
+ # 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
172
  xml.xpath("//*[local-name()='oMath' or local-name()='oMathPara']").each do |x|
167
173
  # prepare input: delete xmlns & change
168
174
  input = Nokogiri::XML(x.to_xml.sub(/<m:(oMath|oMathPara)>/,
169
175
  "<m:\\1 xmlns:m='http://schemas.openxmlformats.org/officeDocument/2006/math'>"))
170
176
  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"}, "")
177
+ mml = out.to_xml.gsub(/<\?xml[^>]+>/, "")
178
+ .gsub(%r{<([^:/! >]+ xmlns="http://www.w3.org/1998/Math/MathML")},
179
+ "<mml:\\1")
180
+ .gsub(%r{<([^:/!>]+)>}, "<mml:\\1>")
181
+ .gsub(%r{</([^:/!>]+)>}, "</mml:\\1>")
182
+ .gsub(%r{ xmlns="http://www.w3.org/1998/Math/MathML"}, "")
183
+ .gsub(%r{ xmlns:mml="http://www.w3.org/1998/Math/MathML"}, "")
184
+ .gsub(%r{ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"}, "")
185
+ .gsub(%r{ xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math"}, "")
180
186
  x.replace("<mml:math>#{mml}</mml:math>")
181
187
  end
182
188
  xml.to_s
@@ -1,4 +1,4 @@
1
1
  module Omml2Mathml
2
- VERSION = "0.0.11".freeze
2
+ VERSION = "0.0.12".freeze
3
3
  end
4
4
 
data/omml2mathml.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
24
24
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
25
25
 
26
- spec.add_dependency "nokogiri", "~> 1.12"
26
+ spec.add_dependency "nokogiri", "~> 1"
27
27
  spec.add_development_dependency "bundler"
28
28
  spec.add_development_dependency "debug"
29
29
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omml2mathml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2022-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: '1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
215
  requirements: []
216
- rubygems_version: 3.2.22
216
+ rubygems_version: 3.3.9
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Convert Office Math Markup to MathML