@@ -167,7 +167,8 @@ def mathml_to_ooml1(xml, docnamespaces)
167167 doc . root = ooxml_cleanup ( xml , docnamespaces )
168168 # d = xml.parent["block"] != "false" # display_style
169169 ooxml = Nokogiri ::XML ( Plurimath ::Math
170- . parse ( doc . root . to_xml ( indent : 0 ) , :mathml ) . to_omml ( split_on_linebreak : true ) )
170+ . parse ( doc . root . to_xml ( indent : 0 ) , :mathml )
171+ . to_omml ( split_on_linebreak : true ) )
171172 ooxml = unitalic ( accent_tr ( ooxml ) )
172173 ooxml = ooml_clean ( uncenter ( xml , ooxml ) )
173174 xml . swap ( ooxml )
@@ -217,15 +218,20 @@ def uncenter(math, ooxml)
217218 alignnode = math . xpath ( STYLE_BEARING_NODE ) . last
218219 ooxml . document? and ooxml = ooxml . root
219220 ret = uncenter_unneeded ( math , ooxml , alignnode ) and return ret
220- dir = "left"
221- alignnode [ "style" ] &.include? ( "text-align:right" ) and dir = "right"
222- ooxml . name == "oMathPara" or
223- ooxml . wrap ( "<m:oMathPara></m:oMathPara>" )
221+ dir = ooxml_alignment ( alignnode )
222+ ooxml . name == "oMathPara" or ooxml . wrap ( "<m:oMathPara></m:oMathPara>" )
224223 ooxml . elements . first . previous =
225224 "<m:oMathParaPr><m:jc m:val='#{ dir } '/></m:oMathParaPr>"
226225 ooxml
227226 end
228227
228+ def ooxml_alignment ( alignnode )
229+ dir = "left"
230+ /text-align:\s *right/ . match? ( alignnode [ "style" ] ) and dir = "right"
231+ /text-align:\s *center/ . match? ( alignnode [ "style" ] ) and dir = "center"
232+ dir
233+ end
234+
229235 def uncenter_unneeded ( math , ooxml , alignnode )
230236 ( math_block? ( ooxml , math ) || !alignnode ) and return ooxml
231237 math_only_para? ( alignnode ) and return nil
0 commit comments