html2doc 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aa0a8504ff535fa43595e3839d7de18fbb8a7cbb3b2ed303d1965656814dfe3
4
- data.tar.gz: a56eb2333cd28420e7f8001f37edc9db5dc9b07f21eed192b02c35184e45c7af
3
+ metadata.gz: 89f05f87cd25266b64654929b7087a07c912fcf8b24beb33f2faceb5123da190
4
+ data.tar.gz: de12518aafb1ac65bf1f4addf76f16ff246c58aa99561e321dc3d8af7cd0a623
5
5
  SHA512:
6
- metadata.gz: '01291816da883daad14800ad3cdb41bc611c5698c9bec518c52fd0a67f133f8fd367d1b129ceb8827f214834fb970a5bbaa2f4e7d4af404bd221aca2dec61e78'
7
- data.tar.gz: fd8119ee883d255d10e9882f3541adae2f57c9631dcec451dde230d252e101096afe0b3dd090ebe8cf31cc45f2339e452c3d55f08ac13110c1b41f11faac8ba5
6
+ metadata.gz: 535aa46b12785253d9b5ebacf7f0c70f2f7045a5367dbf3ae2c023188a6005be39f6f003574d7855ca8ca2e757ddcde2f5128602e18156699248281fa6db4502
7
+ data.tar.gz: 5452e2880c9ba6f231d02039e5f2b2054e5535c903539f34804c65aeb77b63361994fd604f9d3d92ce808244fa5c46e9fc790f747041955606a1a474bdd02449
@@ -29,7 +29,6 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
32
  - name: Update gems
34
33
  run: |
35
34
  sudo gem install bundler --force
@@ -31,7 +31,6 @@ jobs:
31
31
  uses: actions/setup-ruby@v1
32
32
  with:
33
33
  ruby-version: ${{ matrix.ruby }}
34
- architecture: 'x64'
35
34
  - name: Update gems
36
35
  run: |
37
36
  gem install bundler
@@ -39,15 +38,19 @@ jobs:
39
38
  - name: Run specs
40
39
  run: |
41
40
  bundle exec rake
42
- - name: Trigger dependent repositories
43
- if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
41
+ - name: Trigger repositories
42
+ if: matrix.ruby == '2.6'
44
43
  env:
45
- GH_USERNAME: ${{ secrets.PAT_USERNAME }}
46
- GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
44
+ GH_USERNAME: metanorma-ci
45
+ GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
47
46
  run: |
48
47
  curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
49
48
  [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
50
- for repo in $DEPENDENT_REPOS
49
+ CLIENT_PAYLOAD=$(cat <<EOF
50
+ "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
51
+ EOF
52
+ )
53
+ for repo in $REPOS
51
54
  do
52
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "{ \"ref\": \"${GITHUB_REF}\" }"
55
+ sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
53
56
  done
@@ -29,7 +29,6 @@ jobs:
29
29
  uses: actions/setup-ruby@v1
30
30
  with:
31
31
  ruby-version: ${{ matrix.ruby }}
32
- architecture: 'x64'
33
32
  - name: Update gems
34
33
  shell: pwsh
35
34
  run: |
@@ -9,7 +9,8 @@ module Html2Doc
9
9
  encoding: "utf-8"))
10
10
 
11
11
  def self.asciimath_to_mathml1(x)
12
- AsciiMath.parse(HTMLEntities.new.decode(x)).to_mathml.
12
+ AsciiMath::MathMLBuilder.new(:msword => true).append_expression(
13
+ AsciiMath.parse(HTMLEntities.new.decode(x)).ast).to_s.
13
14
  gsub(/<math>/, "<math xmlns='http://www.w3.org/1998/Math/MathML'>")
14
15
  end
15
16
 
@@ -31,6 +32,9 @@ module Html2Doc
31
32
  next unless x.next_element && x.next_element != "mrow"
32
33
  x.next_element.wrap("<mrow/>")
33
34
  end
35
+ m.xpath(".//xmlns:mtext", docnamespaces).each do |x|
36
+ x.children = x.children.to_xml.gsub(/^\s/, "&#xA0;").gsub(/\s$/, "&#xA0;")
37
+ end
34
38
  m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
35
39
  m
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module Html2Doc
2
- VERSION = "1.0.3".freeze
2
+ VERSION = "1.0.4".freeze
3
3
  end
@@ -374,7 +374,7 @@ RSpec.describe Html2Doc do
374
374
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
375
375
  #{word_body(%{
376
376
  <div><m:oMath>
377
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:r><m:t>(</m:t></m:r><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:r><m:t>(</m:t></m:r><m:r><m:t>n+1</m:t></m:r><m:r><m:t>)</m:t></m:r></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f><m:r><m:t>)</m:t></m:r></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>"integer"</m:t></m:r><m:r><m:t>)</m:t></m:r>
377
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>"integer"</m:t></m:r><m:r><m:t>)</m:t></m:r>
378
378
  </m:oMath>
379
379
  </div>}, '<div style="mso-element:footnote-list"/>')}
380
380
  #{WORD_FTR1}
@@ -388,13 +388,28 @@ RSpec.describe Html2Doc do
388
388
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
389
389
  #{word_body("
390
390
  <div><m:oMath>
391
- <m:r><m:t>text</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>integer</m:t></m:r><m:r><m:t>)</m:t></m:r>
391
+ <m:r><m:t>text</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>&#xA0;integer&#xA0;</m:t></m:r><m:r><m:t>)</m:t></m:r>
392
392
  </m:oMath>
393
393
  </div>", '<div style="mso-element:footnote-list"/>')}
394
394
  #{WORD_FTR1}
395
395
  OUTPUT
396
396
  end
397
397
 
398
+ it "processes spaces in MathML mtext" do
399
+ Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
400
+ <mrow><mi>H</mi><mtext> original </mtext><mi>J</mi></mrow>
401
+ </math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
402
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
403
+ to match_fuzzy(<<~OUTPUT)
404
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
405
+ #{word_body('<div><m:oMath>
406
+ <m:r><m:t>H</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>&#xA0;original&#xA0;</m:t></m:r><m:r><m:t>J</m:t></m:r>
407
+ </m:oMath>
408
+ </div>', '<div style="mso-element:footnote-list"/>')}
409
+ #{WORD_FTR1}
410
+ OUTPUT
411
+ end
412
+
398
413
  it "left-aligns AsciiMath" do
399
414
  Html2Doc.process(html_input("<div style='text-align:left;'>{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}</div>"), filename: "test", asciimathdelims: ["{{", "}}"])
400
415
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
@@ -402,7 +417,7 @@ RSpec.describe Html2Doc do
402
417
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
403
418
  #{word_body(%{
404
419
  <div style="text-align:left;"><m:oMathPara><m:oMathParaPr><m:jc m:val="left"/></m:oMathParaPr><m:oMath>
405
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:r><m:t>(</m:t></m:r><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:r><m:t>(</m:t></m:r><m:r><m:t>n+1</m:t></m:r><m:r><m:t>)</m:t></m:r></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f><m:r><m:t>)</m:t></m:r></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
420
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
406
421
  </m:oMath>
407
422
  </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
408
423
  #{WORD_FTR1}
@@ -416,7 +431,7 @@ RSpec.describe Html2Doc do
416
431
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
417
432
  #{word_body(%{
418
433
  <div style="text-align:right;"><m:oMathPara><m:oMathParaPr><m:jc m:val="right"/></m:oMathParaPr><m:oMath>
419
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:r><m:t>(</m:t></m:r><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:r><m:t>(</m:t></m:r><m:r><m:t>n+1</m:t></m:r><m:r><m:t>)</m:t></m:r></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f><m:r><m:t>)</m:t></m:r></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
434
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
420
435
  </m:oMath>
421
436
  </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
422
437
  #{WORD_FTR1}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html2doc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -309,7 +309,7 @@ licenses:
309
309
  - CC-BY-SA-3.0
310
310
  - BSD-2-Clause
311
311
  metadata: {}
312
- post_install_message:
312
+ post_install_message:
313
313
  rdoc_options: []
314
314
  require_paths:
315
315
  - lib
@@ -324,9 +324,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
324
  - !ruby/object:Gem::Version
325
325
  version: '0'
326
326
  requirements: []
327
- rubyforge_project:
328
- rubygems_version: 2.7.6
329
- signing_key:
327
+ rubygems_version: 3.0.3
328
+ signing_key:
330
329
  specification_version: 4
331
330
  summary: Convert HTML document to Microsoft Word document
332
331
  test_files: []