html2doc 1.0.0 → 1.0.5

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: 6dacc967f64994c36c4566869a97848278dce24d5318417dc0e9a901bb4fa9ae
4
- data.tar.gz: d96f332a360c7aa04b8c8d5931274737b7c31349ab28cc7e04e34785e0675169
3
+ metadata.gz: 6616c37575b4bd09b8b7bf7a89beffece7388f3e2a4039610825a030ffb72318
4
+ data.tar.gz: f29a3348e0b9260c4178af9a7f939e8ec39c2401cdc321346e5a6321e862cbad
5
5
  SHA512:
6
- metadata.gz: 6e059a12f8d8bb192b31e4d573f6a661e9091a474a6da3c2c60e81e9ee99cf45251da0f5a5badf23ebd9cd913e0ce47e35fe3b7a3ac4e0610626af6c0eba27c6
7
- data.tar.gz: dce3f36d0006eebc92e01a12e62dc826329487ebfd6186d425561991175cf6c7057f569bb1dc49ff14a9d471dedf64c236ae60da5cc265374329a2ec1f9dc302
6
+ metadata.gz: 4dee0b6541178293833caf2d55e1ec382ea16692b4efe4455ff0fd627e89ef5e67be747248cefd6c56ff151d8f9ea46f54633241d90996055e3574604eed175e
7
+ data.tar.gz: da5201fa1568f34e0638947d6dcfb5df1b7cf4303de1f74323122fcf92f6060cc7d5ddcc483cbfbfcb70798d12afc95c89b48d0274a34114fd8b18d7c1d58692
@@ -1,28 +1,34 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: macos
4
4
 
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
- branches: [ '**' ]
9
+ paths-ignore:
10
+ - .github/workflows/ubuntu.yml
11
+ - .github/workflows/windows.yml
10
12
 
11
13
  jobs:
12
14
  test-macos:
13
15
  name: Test on Ruby ${{ matrix.ruby }} macOS
14
16
  runs-on: macos-latest
17
+ continue-on-error: ${{ matrix.experimental }}
15
18
  strategy:
16
19
  fail-fast: false
17
20
  matrix:
18
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
19
26
  steps:
20
27
  - uses: actions/checkout@master
21
28
  - name: Use Ruby
22
29
  uses: actions/setup-ruby@v1
23
30
  with:
24
31
  ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
32
  - name: Update gems
27
33
  run: |
28
34
  sudo gem install bundler --force
@@ -1,32 +1,56 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: ubuntu
4
4
 
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
+ tags:
9
+ - '*'
8
10
  pull_request:
9
- branches: [ '**' ]
11
+ paths-ignore:
12
+ - .github/workflows/macos.yml
13
+ - .github/workflows/windows.yml
10
14
 
11
15
  jobs:
12
16
  test-linux:
13
17
  name: Test on Ruby ${{ matrix.ruby }} Ubuntu
14
18
  runs-on: ubuntu-latest
19
+ continue-on-error: ${{ matrix.experimental }}
15
20
  strategy:
16
21
  fail-fast: false
17
22
  matrix:
18
23
  ruby: [ '2.6', '2.5', '2.4' ]
24
+ experimental: [false]
25
+ include:
26
+ - ruby: '2.7'
27
+ experimental: true
19
28
  steps:
20
29
  - uses: actions/checkout@master
21
30
  - name: Use Ruby
22
31
  uses: actions/setup-ruby@v1
23
32
  with:
24
33
  ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
34
  - name: Update gems
27
35
  run: |
28
- gem install bundler
36
+ gem install bundler
29
37
  bundle install --jobs 4 --retry 3
30
38
  - name: Run specs
31
39
  run: |
32
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
@@ -1,34 +1,39 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
3
  name: windows
4
4
 
5
5
  on:
6
6
  push:
7
7
  branches: [ master ]
8
8
  pull_request:
9
- branches: [ '**' ]
9
+ paths-ignore:
10
+ - .github/workflows/macos.yml
11
+ - .github/workflows/ubuntu.yml
10
12
 
11
13
  jobs:
12
14
  test-windows:
13
15
  name: Test on Ruby ${{ matrix.ruby }} Windows
14
16
  runs-on: windows-latest
17
+ continue-on-error: ${{ matrix.experimental }}
15
18
  strategy:
16
19
  fail-fast: false
17
20
  matrix:
18
21
  ruby: [ '2.6', '2.5', '2.4' ]
22
+ experimental: [false]
23
+ include:
24
+ - ruby: '2.7'
25
+ experimental: true
19
26
  steps:
20
27
  - uses: actions/checkout@master
21
28
  - name: Use Ruby
22
29
  uses: actions/setup-ruby@v1
23
30
  with:
24
31
  ruby-version: ${{ matrix.ruby }}
25
- architecture: 'x64'
26
32
  - name: Update gems
27
33
  shell: pwsh
28
34
  run: |
29
- gem install bundler
35
+ gem install bundler
30
36
  bundle config --local path vendor/bundle
31
- bundle update
32
37
  bundle install --jobs 4 --retry 3
33
38
  - name: Run specs
34
39
  run: |
@@ -3,8 +3,9 @@
3
3
  https://github.com/metanorma/html2doc/workflows/main/badge.svg
4
4
 
5
5
  image:https://img.shields.io/gem/v/html2doc.svg["Gem Version", link="https://rubygems.org/gems/html2doc"]
6
- image:https://travis-ci.com/metanorma/html2doc.svg["Build Status", link="https://travis-ci.com/metanorma/html2doc"]
7
- image:https://ci.appveyor.com/api/projects/status/aspj42o70q3dnkf1?svg=true["Appveyor Build Status", link="https://ci.appveyor.com/project/metanorma/html2doc"]
6
+ image:https://github.com/metanorma/html2doc/workflows/ubuntu/badge.svg["Ubuntu Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Aubuntu"]
7
+ image:https://github.com/metanorma/html2doc/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Amacos"]
8
+ image:https://github.com/metanorma/html2doc/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Awindows"]
8
9
  image:https://codeclimate.com/github/metanorma/html2doc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/html2doc"]
9
10
  image:https://img.shields.io/github/issues-pr-raw/metanorma/html2doc.svg["Pull Requests", link="https://github.com/metanorma/html2doc/pulls"]
10
11
  image:https://img.shields.io/github/commits-since/metanorma/html2doc/latest.svg["Commits since latest",link="https://github.com/metanorma/html2doc/releases"]
@@ -23,7 +24,7 @@ This work is driven by the Word document generation procedure documented in http
23
24
 
24
25
  The gem currently does the following:
25
26
 
26
- * Convert any AsciiMath and MathML to Word's native mathematical formatting language, OOXML. Word supports copy-pasting MathML into Word and converting it into OOXML; however the conversion is not infallible (we have found problems with `\sum`: Word claims parameters were missing, and inserting dotted squares to indicate as much), and you may need to post-edit the OOXML.
27
+ * Convert any AsciiMath and MathML to Word's native mathematical formatting language, OOXML. Word supports copy-pasting MathML into Word and converting it into OOXML; however the conversion is not infallible (we have in the past found problems with `\sum`: Word claims parameters were missing, and inserting dotted squares to indicate as much), and you may need to post-edit the OOXML.
27
28
  ** The gem does attempt to repair the MathML input, to bring it in line with Word's OOXML's expectations. If you find any issues with AsciiMath or MathML input, please raise an issue.
28
29
  * Identify any footnotes in the document (defined as hyperlinks with attributes `class = "Footnote"` or `epub:type = "footnote"`), and render them as Microsoft Word footnotes.
29
30
  ** The corresponding footnote content is any `div` or `aside` element with the same `@id` attribute as the footnote points to; e.g. `<a href="#ftn1" epub:type="footnote"><sup>3</sup></a></span>`, pointing to `<aside id="ftn3">`.
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "nokogiri", ">= 1.10.4"
32
32
  spec.add_dependency "thread_safe"
33
33
  spec.add_dependency "uuidtools"
34
- spec.add_dependency "asciimath", "~> 1.0.9"
34
+ spec.add_dependency "asciimath", "~> 2.0.0"
35
35
 
36
36
  spec.add_development_dependency "byebug", "~> 9.1"
37
37
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -2,7 +2,7 @@ require "uuidtools"
2
2
  require "asciimath"
3
3
  require "htmlentities"
4
4
  require "nokogiri"
5
- require "pp"
5
+ require "uuidtools"
6
6
 
7
7
  module Html2Doc
8
8
  def self.style_list(li, level, liststyle, listnumber)
@@ -15,13 +15,8 @@ module Html2Doc
15
15
  li["style"] += "mso-list:#{liststyle} level#{level} lfo#{listnumber};"
16
16
  end
17
17
 
18
- def self.list_add(xpath, liststyles, listtype, level)
19
- xpath.each_with_index do |list, i|
20
- @listnumber += 1 if level == 1
21
- list["seen"] = true if level == 1
22
- (list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |li|
23
- style_list(li, level, liststyles[listtype], @listnumber)
24
- if [:ul, :ol].include? listtype
18
+ def self.list_add1(li, liststyles, listtype, level)
19
+ if [:ul, :ol].include? listtype
25
20
  list_add(li.xpath(".//ul") - li.xpath(".//ul//ul | .//ol//ul"),
26
21
  liststyles, :ul, level + 1)
27
22
  list_add(li.xpath(".//ol") - li.xpath(".//ul//ol | .//ol//ol"),
@@ -32,6 +27,20 @@ module Html2Doc
32
27
  list_add(li.xpath(".//ol") - li.xpath(".//ul//ol | .//ol//ol"),
33
28
  liststyles, listtype, level + 1)
34
29
  end
30
+ end
31
+
32
+ def self.list_add(xpath, liststyles, listtype, level)
33
+ xpath.each_with_index do |list, i|
34
+ @listnumber += 1 if level == 1
35
+ list["seen"] = true if level == 1
36
+ list["id"] ||= UUIDTools::UUID.random_create
37
+ (list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |li|
38
+ style_list(li, level, liststyles[listtype], @listnumber)
39
+ list_add1(li, liststyles, listtype, level)
40
+ end
41
+ list.xpath(".//ul[not(ancestor::li/ancestor::*/@id = '#{list['id']}')] | "\
42
+ ".//ol[not(ancestor::li/ancestor::*/@id = '#{list['id']}')]").each do |li|
43
+ list_add1(li.parent, liststyles, listtype, level-1)
35
44
  end
36
45
  end
37
46
  end
@@ -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
 
@@ -26,12 +27,40 @@ module Html2Doc
26
27
 
27
28
  # random fixes to MathML input that OOXML needs to render properly
28
29
  def self.ooxml_cleanup(m, docnamespaces)
30
+ m = mathml_preserve_space(mathml_insert_rows(m, docnamespaces), docnamespaces)
31
+ m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
32
+ m
33
+ end
34
+
35
+ def self.mathml_insert_rows(m, docnamespaces)
29
36
  m.xpath(%w(msup msub msubsup munder mover munderover).
30
37
  map { |m| ".//xmlns:#{m}" }.join(" | "), docnamespaces).each do |x|
31
38
  next unless x.next_element && x.next_element != "mrow"
32
39
  x.next_element.wrap("<mrow/>")
33
40
  end
34
- m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
41
+ m
42
+ end
43
+
44
+ def self.mathml_preserve_space(m, docnamespaces)
45
+ m.xpath(".//xmlns:mtext", docnamespaces).each do |x|
46
+ x.children = x.children.to_xml.gsub(/^\s/, "&#xA0;").gsub(/\s$/, "&#xA0;")
47
+ end
48
+ m
49
+ end
50
+
51
+ def self.unitalic(m)
52
+ m.xpath(".//xmlns:r[xmlns:rPr/xmlns:sty[@m:val = 'p']]").each do |x|
53
+ x.wrap("<span style='font-style:normal;'></span>")
54
+ end
55
+ m.xpath(".//xmlns:r[xmlns:rPr/xmlns:sty[@m:val = 'bi']]").each do |x|
56
+ x.wrap("<span style='font-style:italic;font-weight:bold;'></span>")
57
+ end
58
+ m.xpath(".//xmlns:r[xmlns:rPr/xmlns:sty[@m:val = 'i']]").each do |x|
59
+ x.wrap("<span class='nostem'><em></em></span>")
60
+ end
61
+ m.xpath(".//xmlns:r[xmlns:rPr/xmlns:sty[@m:val = 'b']]").each do |x|
62
+ x.wrap("<span style='font-style:normal;font-weight:bold;'></span>")
63
+ end
35
64
  m
36
65
  end
37
66
 
@@ -44,10 +73,10 @@ module Html2Doc
44
73
  element = ooxml_cleanup(x, docnamespaces)
45
74
  doc = Nokogiri::XML::Document::new()
46
75
  doc.root = element
47
- ooxml = (esc_space(@xsltemplate.transform(doc))).to_s.
76
+ ooxml = (unitalic(esc_space(@xsltemplate.transform(doc)))).to_s.
48
77
  gsub(/<\?[^>]+>\s*/, "").
49
78
  gsub(/ xmlns(:[^=]+)?="[^"]+"/, "").
50
- gsub(%r{<(/)?([a-z])}, "<\\1m:\\2")
79
+ gsub(%r{<(/)?(?!span)(?!em)([a-z])}, "<\\1m:\\2")
51
80
  ooxml = uncenter(x, ooxml)
52
81
  x.swap(ooxml)
53
82
  end
@@ -68,6 +68,7 @@ module Html2Doc
68
68
  realSize = ImageSize.path(path).size
69
69
  s = [i["width"].to_i, i["height"].to_i]
70
70
  s = realSize if s[0].zero? && s[1].zero?
71
+ return [nil, nil] if realSize[0].nil? || realSize[1].nil?
71
72
  s[1] = s[0] * realSize[1] / realSize[0] if s[1].zero? && !s[0].zero?
72
73
  s[0] = s[1] * realSize[0] / realSize[1] if s[0].zero? && !s[1].zero?
73
74
  s = [(s[0] * maxheight / s[1]).ceil, maxheight] if s[1] > maxheight
@@ -878,9 +878,21 @@
878
878
  </xsl:otherwise>
879
879
  </xsl:choose>
880
880
  </xsl:if>
881
- </xsl:variable>
881
+ </xsl:variable>
882
+ <!-- NN 20200831 https://github.com/metanorma/metanorma-nist/issues/155 Read in ancestor mstyle -->
883
+ <xsl:variable name="mathvariant2">
884
+ <xsl:choose>
885
+ <xsl:when test="$mathvariant=''">
886
+ <xsl:value-of select="$ndCur/ancestor::mml:mstyle[@mathvariant][1]/@mathvariant"/>
887
+ </xsl:when>
888
+ <xsl:otherwise>
889
+ <xsl:value-of select="$mathvariant"/>
890
+ </xsl:otherwise>
891
+ </xsl:choose>
892
+ </xsl:variable>
893
+ <!-- END NN -->
882
894
  <xsl:call-template name="CreateMathRPR">
883
- <xsl:with-param name="mathvariant" select="$mathvariant"/>
895
+ <xsl:with-param name="mathvariant" select="$mathvariant2"/>
884
896
  <xsl:with-param name="fontstyle" select="$fontstyle"/>
885
897
  <xsl:with-param name="fontweight" select="$fontweight"/>
886
898
  <xsl:with-param name="ndCur" select="$ndCur"/>
@@ -905,7 +917,7 @@
905
917
  <xsl:with-param name="fontweight" select="$fontweight"/>
906
918
  <xsl:with-param name="ndCur" select="$ndCur"/>
907
919
  </xsl:call-template>
908
- </xsl:variable>
920
+ </xsl:variable>
909
921
  <xsl:if test="$fLit=1 or $fNor=1 or ($sFontCur!='italic' and $sFontCur!='')">
910
922
  <rPr>
911
923
  <xsl:if test="$fNor=1">
@@ -919,7 +931,7 @@
919
931
  <xsl:with-param name="fNor" select="$fNor"/>
920
932
  </xsl:call-template>
921
933
  </rPr>
922
- </xsl:if>
934
+ </xsl:if>
923
935
  </xsl:template>
924
936
 
925
937
  <!-- %%Template: GetFontCur
@@ -935,8 +947,10 @@
935
947
  </xsl:when>
936
948
  <xsl:when test="not($ndCur)">
937
949
  <xsl:value-of select="'italic'"/>
938
- </xsl:when>
939
- <xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) &lt;= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN' or $ndCur/self::mml:mo">
950
+ </xsl:when>
951
+ <!--<xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) &lt;= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN' or $ndCur/self::mml:mo">-->
952
+ <!-- https://github.com/metanorma/metanorma-nist/issues/155 : DO NOT italicise mml:mo -->
953
+ <xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) &lt;= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN'">
940
954
 
941
955
  <!-- The default for the above three cases is fontstyle=italic fontweight=normal.-->
942
956
  <xsl:choose>
@@ -1000,6 +1014,12 @@
1000
1014
  </sty>
1001
1015
  </xsl:when>
1002
1016
  <xsl:when test="$font='italic'">
1017
+ <!-- NN 20200901 https://github.com/metanorma/metanorma-itu/issues/173 italic needs to be added explicitly to mtext -->
1018
+ <xsl:if test="$fNor=1">
1019
+ <sty>
1020
+ <xsl:attribute name="m:val">i</xsl:attribute>
1021
+ </sty>
1022
+ </xsl:if>
1003
1023
  </xsl:when>
1004
1024
  <xsl:when test="$font='script'">
1005
1025
  <scr>
@@ -1,3 +1,3 @@
1
1
  module Html2Doc
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.5".freeze
3
3
  end
@@ -372,11 +372,25 @@ RSpec.describe Html2Doc do
372
372
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
373
373
  to match_fuzzy(<<~OUTPUT)
374
374
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
375
- #{word_body("
375
+ #{word_body(%{
376
376
  <div><m:oMath>
377
- #{ASCII_MATH}<m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>\"integer\"</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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
378
378
  </m:oMath>
379
- </div>", '<div style="mso-element:footnote-list"/>')}
379
+ </div>}, '<div style="mso-element:footnote-list"/>')}
380
+ #{WORD_FTR1}
381
+ OUTPUT
382
+ end
383
+
384
+ it "processes mstyle" do
385
+ Html2Doc.process(html_input(%[<div>{{bb (-log_2 (p_u)) bb "AA" bbb "AA" cc "AA" tt "AA" fr "AA" sf "AA" ii "AA"}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"])
386
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
387
+ to match_fuzzy(<<~OUTPUT)
388
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
389
+ #{word_body(%{
390
+ <div><m:oMath>
391
+ <span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x2212;</m:t></m:r></span><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>log</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>2</m:t></m:r></span></m:sub></m:sSub><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>p</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>u</m:t></m:r></span></m:sub></m:sSub></m:e></m:d><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:nor></m:nor><m:sty m:val="b"></m:sty></m:rPr><m:t>AA</m:t></m:r></span><span style="font-style:normal;"><m:r><m:rPr><m:nor></m:nor><m:scr m:val="double-struck"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>AA</m:t></m:r></span><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr></m:rPr><m:t>AA</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>AA</m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>AA</m:t></m:r></span><span style="font-style:normal;"><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>AA</m:t></m:r></span><span class="nostem"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="i"></m:sty></m:rPr><m:t>AA</m:t></m:r></span>
392
+ </m:oMath>
393
+ </div>}, '<div style="mso-element:footnote-list"/>')}
380
394
  #{WORD_FTR1}
381
395
  OUTPUT
382
396
  end
@@ -386,11 +400,26 @@ RSpec.describe Html2Doc do
386
400
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
387
401
  to match_fuzzy(<<~OUTPUT)
388
402
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
389
- #{word_body("
403
+ #{word_body('
390
404
  <div><m:oMath>
391
- <m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>integer</m:t></m:r>
405
+ <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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
392
406
  </m:oMath>
393
- </div>", '<div style="mso-element:footnote-list"/>')}
407
+ </div>', '<div style="mso-element:footnote-list"/>')}
408
+ #{WORD_FTR1}
409
+ OUTPUT
410
+ end
411
+
412
+ it "processes spaces in MathML mtext" do
413
+ Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
414
+ <mrow><mi>H</mi><mtext> original </mtext><mi>J</mi></mrow>
415
+ </math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
416
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
417
+ to match_fuzzy(<<~OUTPUT)
418
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
419
+ #{word_body('<div><m:oMath>
420
+ <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>
421
+ </m:oMath>
422
+ </div>', '<div style="mso-element:footnote-list"/>')}
394
423
  #{WORD_FTR1}
395
424
  OUTPUT
396
425
  end
@@ -400,11 +429,11 @@ RSpec.describe Html2Doc do
400
429
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
401
430
  to match_fuzzy(<<~OUTPUT)
402
431
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
403
- #{word_body("
404
- <div style=\"text-align:left;\"><m:oMathPara><m:oMathParaPr><m:jc m:val=\"left\"/></m:oMathParaPr><m:oMath>
405
- #{ASCII_MATH}
432
+ #{word_body(%{
433
+ <div style="text-align:left;"><m:oMathPara><m:oMathParaPr><m:jc m:val="left"/></m:oMathParaPr><m:oMath>
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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><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
435
  </m:oMath>
407
- </m:oMathPara></div>", '<div style="mso-element:footnote-list"/>')}
436
+ </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
408
437
  #{WORD_FTR1}
409
438
  OUTPUT
410
439
  end
@@ -414,11 +443,11 @@ RSpec.describe Html2Doc do
414
443
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
415
444
  to match_fuzzy(<<~OUTPUT)
416
445
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
417
- #{word_body("
418
- <div style=\"text-align:right;\"><m:oMathPara><m:oMathParaPr><m:jc m:val=\"right\"/></m:oMathParaPr><m:oMath>
419
- #{ASCII_MATH}
446
+ #{word_body(%{
447
+ <div style="text-align:right;"><m:oMathPara><m:oMathParaPr><m:jc m:val="right"/></m:oMathParaPr><m:oMath>
448
+ <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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><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
449
  </m:oMath>
421
- </m:oMathPara></div>", '<div style="mso-element:footnote-list"/>')}
450
+ </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
422
451
  #{WORD_FTR1}
423
452
  OUTPUT
424
453
  end
@@ -655,15 +684,16 @@ RSpec.describe Html2Doc do
655
684
 
656
685
  it "labels lists with list styles" do
657
686
  simple_body = <<~BODY
658
- <div><ul>
659
- <li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
687
+ <div><ul id="0">
688
+ <li><div><p><ol id="1"><li><ul id="2"><li><p><ol id="3"><li><ol id="4"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li><div><ul id="5"><li>C</li></ul></div>
660
689
  BODY
661
690
  Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
662
691
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
663
692
  to match_fuzzy(<<~OUTPUT)
664
693
  #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
665
694
  #{word_body('<div>
666
- <p style="mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>',
695
+ <p style="mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p><div><p style="mso-list:l1 level1 lfo2;" class="MsoListParagraphCxSpFirst">C</p></div>
696
+ </div>',
667
697
  '<div style="mso-element:footnote-list"/>')}
668
698
  #{WORD_FTR1}
669
699
  OUTPUT
@@ -673,8 +703,8 @@ RSpec.describe Html2Doc do
673
703
  it "restarts numbering of lists with list styles" do
674
704
  simple_body = <<~BODY
675
705
  <div>
676
- <ol><li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol>
677
- <ol><li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol></div>
706
+ <ol id="1"><li><div><p><ol id="2"><li><ul id="3"><li><p><ol id="4"><li><ol id="5"><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol>
707
+ <ol id="6"><li><div><p><ol id="7"><li><ul id="8"><li><p><ol id="9"><li><ol id="10"><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol></div>
678
708
  BODY
679
709
  Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
680
710
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
@@ -690,12 +720,12 @@ RSpec.describe Html2Doc do
690
720
 
691
721
  it "labels lists with multiple list styles" do
692
722
  simple_body = <<~BODY
693
- <div><ul class="steps">
694
- <li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
695
- <div><ul>
696
- <li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
697
- <div><ul class="other">
698
- <li><div><p><ol><li><ul><li><p><ol><li><ol><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
723
+ <div><ul class="steps" id="0">
724
+ <li><div><p><ol id="1"><li><ul id="2"><li><p><ol id="3"><li><ol id="4"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
725
+ <div><ul id="5">
726
+ <li><div><p><ol id="6"><li><ul id="7"><li><p><ol id="8"><li><ol id="9"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
727
+ <div><ul class="other" id="10">
728
+ <li><div><p><ol id="11"><li><ul id="12"><li><p><ol id="13"><li><ol id="14"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
699
729
  BODY
700
730
  Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2", steps: "l3"})
701
731
  expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
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.0
4
+ version: 1.0.5
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-03-05 00:00:00.000000000 Z
11
+ date: 2020-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.9
103
+ version: 2.0.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.9
110
+ version: 2.0.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: byebug
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -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: []