html2doc 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +2 -3
- data/.github/workflows/ubuntu.yml +15 -4
- data/.github/workflows/windows.yml +3 -5
- data/README.adoc +3 -2
- data/lib/html2doc/lists.rb +17 -8
- data/lib/html2doc/version.rb +1 -1
- data/spec/html2doc_spec.rb +12 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89d882e956a68ad2f948882f54494709cb4421bd25e18fccb9415d95f9664d02
|
4
|
+
data.tar.gz: 20836a167e277229f9780ec5fa816ad7fe31778f00c5cc5aaf7365a145203f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bea212f0ad5beac524d671c100237fb15533171074414a08d21dfa316e0af715e70316771c734b868898e6c1977fe985b8aa46d5ee27d9a4abef92908243a55
|
7
|
+
data.tar.gz: 43ee71168d6cddfdc05db3208ab3ad054bc4b95e5da7d288164f5b2ccff944c6322e4defae74055757d7fbfdb77daa789ab70b74dab8283390dc26a70fa3818d
|
data/.github/workflows/macos.yml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
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: [ '**' ]
|
10
9
|
|
11
10
|
jobs:
|
12
11
|
test-macos:
|
@@ -1,12 +1,11 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
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
8
|
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
9
|
|
11
10
|
jobs:
|
12
11
|
test-linux:
|
@@ -25,8 +24,20 @@ jobs:
|
|
25
24
|
architecture: 'x64'
|
26
25
|
- name: Update gems
|
27
26
|
run: |
|
28
|
-
gem install bundler
|
27
|
+
gem install bundler
|
29
28
|
bundle install --jobs 4 --retry 3
|
30
29
|
- name: Run specs
|
31
30
|
run: |
|
32
31
|
bundle exec rake
|
32
|
+
- name: Trigger dependent repositories
|
33
|
+
if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
|
34
|
+
env:
|
35
|
+
GH_USERNAME: ${{ secrets.PAT_USERNAME }}
|
36
|
+
GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
|
37
|
+
run: |
|
38
|
+
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
|
39
|
+
[[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
|
40
|
+
for repo in $DEPENDENT_REPOS
|
41
|
+
do
|
42
|
+
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "{ \"ref\": \"${GITHUB_REF}\" }"
|
43
|
+
done
|
@@ -1,12 +1,11 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
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: [ '**' ]
|
10
9
|
|
11
10
|
jobs:
|
12
11
|
test-windows:
|
@@ -26,9 +25,8 @@ jobs:
|
|
26
25
|
- name: Update gems
|
27
26
|
shell: pwsh
|
28
27
|
run: |
|
29
|
-
gem install bundler
|
28
|
+
gem install bundler
|
30
29
|
bundle config --local path vendor/bundle
|
31
|
-
bundle update
|
32
30
|
bundle install --jobs 4 --retry 3
|
33
31
|
- name: Run specs
|
34
32
|
run: |
|
data/README.adoc
CHANGED
@@ -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://
|
7
|
-
image:https://
|
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"]
|
data/lib/html2doc/lists.rb
CHANGED
@@ -2,7 +2,7 @@ require "uuidtools"
|
|
2
2
|
require "asciimath"
|
3
3
|
require "htmlentities"
|
4
4
|
require "nokogiri"
|
5
|
-
require "
|
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.
|
19
|
-
|
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
|
data/lib/html2doc/version.rb
CHANGED
data/spec/html2doc_spec.rb
CHANGED
@@ -655,15 +655,16 @@ RSpec.describe Html2Doc do
|
|
655
655
|
|
656
656
|
it "labels lists with list styles" do
|
657
657
|
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>
|
658
|
+
<div><ul id="0">
|
659
|
+
<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
660
|
BODY
|
661
661
|
Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
|
662
662
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
663
663
|
to match_fuzzy(<<~OUTPUT)
|
664
664
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
665
665
|
#{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>
|
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><p style="mso-list:l1 level1 lfo2;" class="MsoListParagraphCxSpFirst">C</p></div>
|
667
|
+
</div>',
|
667
668
|
'<div style="mso-element:footnote-list"/>')}
|
668
669
|
#{WORD_FTR1}
|
669
670
|
OUTPUT
|
@@ -673,8 +674,8 @@ RSpec.describe Html2Doc do
|
|
673
674
|
it "restarts numbering of lists with list styles" do
|
674
675
|
simple_body = <<~BODY
|
675
676
|
<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>
|
677
|
+
<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>
|
678
|
+
<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
679
|
BODY
|
679
680
|
Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
|
680
681
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
@@ -690,12 +691,12 @@ RSpec.describe Html2Doc do
|
|
690
691
|
|
691
692
|
it "labels lists with multiple list styles" do
|
692
693
|
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>
|
694
|
+
<div><ul class="steps" id="0">
|
695
|
+
<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>
|
696
|
+
<div><ul id="5">
|
697
|
+
<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>
|
698
|
+
<div><ul class="other" id="10">
|
699
|
+
<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
700
|
BODY
|
700
701
|
Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2", steps: "l3"})
|
701
702
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|