html2doc 1.4.3 → 1.4.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: bb9828e9edbe4e0dabb525267ac5274793a2691d72eb837f46de3191c3159031
4
- data.tar.gz: 5ad4f6a3856ef6ab784db79db8e4f69fdd2b6aeeb5b179e90f0b7d06c1c55eea
3
+ metadata.gz: '0519bc0cdea11bd73e5ef3c07236793fc46ade0f08e7c36258e8fe0918808907'
4
+ data.tar.gz: 919f5ee2632c524b30a72f5eb9f1c647c386eda1946aab89ea7f74e603e90aa1
5
5
  SHA512:
6
- metadata.gz: 4d904e3cc7747cd0167c440b41d4123a6a46d00709f114149b4784bd9c6824361c26169569a44e0f3837c8d102c3eefea2fa256533fa6dbc492f6d31a13e5234
7
- data.tar.gz: 167943e0582c2fcae1724e9d6c9f38fdefdb2641cd2e5ccd6dfc47ebea7b29a6748e353f58383be314390ea306895da781ab85f9a0ebb070672d17f84d30001b
6
+ metadata.gz: 1c3c6b592ebff133758628ef1cd664a9c7e13390bd63551026c785992f0c6ae770d7593aa5052477e1aa08fedd033d749056857a9bb73b1e5babd4aa2e657ff4
7
+ data.tar.gz: 907db4fb0ae7c64168c5b8436b1d2162591f05d9785928cb393d5e7ea4e7fddc086c96534a81e5d3f42df1c048df5c00b313e08f96dbb91a88b0dd95d3ee6774
data/html2doc.gemspec CHANGED
@@ -20,9 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.bindir = "bin"
22
22
  spec.require_paths = ["lib"]
23
- spec.files = `git ls-files`.split("\n")
24
- spec.test_files = `git ls-files -- {spec}/*`.split("\n")
25
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features|bin|.github)/}) \
25
+ || f.match(%r{Rakefile|bin/rspec})
26
+ end
27
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
26
28
 
27
29
  spec.add_dependency "asciimath", "~> 2.0.2"
28
30
  spec.add_dependency "htmlentities", "~> 4.3.4"
data/lib/html2doc/base.rb CHANGED
@@ -15,6 +15,7 @@ class Html2Doc
15
15
  @debug = hash[:debug]
16
16
  @liststyles = hash[:liststyles]
17
17
  @stylesheet = hash[:stylesheet]
18
+ @c = HTMLEntities.new
18
19
  @xsltemplate =
19
20
  Nokogiri::XSLT(File.read(File.join(File.dirname(__FILE__), "mml2omml.xsl"),
20
21
  encoding: "utf-8"))
@@ -49,7 +50,7 @@ class Html2Doc
49
50
  def create_dir(filename, dir)
50
51
  dir and return clear_dir(dir)
51
52
  dir = "#{filename}_files"
52
- Dir.mkdir(dir) unless File.exists?(dir)
53
+ FileUtils.mkdir_p(dir)
53
54
  clear_dir(dir)
54
55
  end
55
56
 
data/lib/html2doc/math.rb CHANGED
@@ -5,24 +5,26 @@ require "nokogiri"
5
5
  require "plane1converter"
6
6
 
7
7
  class Html2Doc
8
- def asciimath_to_mathml1(expr)
9
- AsciiMath::MathMLBuilder.new(msword: true).append_expression(
10
- AsciiMath.parse(HTMLEntities.new.decode(expr)).ast,
11
- ).to_s
12
- .gsub(/<math>/, "<math xmlns='http://www.w3.org/1998/Math/MathML'>")
8
+ def asciimath_to_mathml1(expr, retain_asciimath)
9
+ ret = AsciiMath::MathMLBuilder.new(msword: true).append_expression(
10
+ AsciiMath.parse(@c.decode(expr)).ast,
11
+ ).to_s.gsub(/<math>/, "<math xmlns='http://www.w3.org/1998/Math/MathML'>")
12
+ retain_asciimath and
13
+ ret += "<asciimath>#{@c.encode(@c.decode(expr), :basic)}</asciimath>"
14
+ ret
13
15
  rescue StandardError => e
14
16
  puts "parsing: #{expr}"
15
17
  puts e.message
16
18
  raise e
17
19
  end
18
20
 
19
- def asciimath_to_mathml(doc, delims)
21
+ def asciimath_to_mathml(doc, delims, retain_asciimath: false)
20
22
  return doc if delims.nil? || delims.size < 2
21
23
 
22
24
  m = doc.split(/(#{Regexp.escape(delims[0])}|#{Regexp.escape(delims[1])})/)
23
25
  m.each_slice(4).map.with_index do |(*a), i|
24
26
  progress_conv(i, 500, (m.size / 4).floor, 1000, "AsciiMath")
25
- a[2].nil? || a[2] = asciimath_to_mathml1(a[2])
27
+ a[2].nil? or a[2] = asciimath_to_mathml1(a[2], retain_asciimath)
26
28
  a.size > 1 ? a[0] + a[2] : a[0]
27
29
  end.join
28
30
  end
@@ -122,7 +124,7 @@ class Html2Doc
122
124
  xml.traverse do |n|
123
125
  next unless n.text?
124
126
 
125
- n.replace(Plane1Converter.conv(HTMLEntities.new.decode(n.text), font))
127
+ n.replace(Plane1Converter.conv(@c.decode(n.text), font))
126
128
  end
127
129
  xml
128
130
  end
@@ -1,3 +1,3 @@
1
1
  class Html2Doc
2
- VERSION = "1.4.3".freeze
2
+ VERSION = "1.4.4".freeze
3
3
  end
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.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-21 00:00:00.000000000 Z
11
+ date: 2022-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -273,8 +273,6 @@ extensions: []
273
273
  extra_rdoc_files: []
274
274
  files:
275
275
  - ".gitattributes"
276
- - ".github/workflows/rake.yml"
277
- - ".github/workflows/release.yml"
278
276
  - ".gitignore"
279
277
  - ".hound.yml"
280
278
  - ".oss-guides.rubocop.yml"
@@ -284,11 +282,6 @@ files:
284
282
  - Gemfile
285
283
  - LICENSE
286
284
  - README.adoc
287
- - Rakefile
288
- - bin/console
289
- - bin/html2doc
290
- - bin/rspec
291
- - bin/setup
292
285
  - html2doc.gemspec
293
286
  - lib/html2doc.rb
294
287
  - lib/html2doc/base.rb
@@ -299,23 +292,6 @@ files:
299
292
  - lib/html2doc/notes.rb
300
293
  - lib/html2doc/version.rb
301
294
  - lib/html2doc/wordstyle.css
302
- - spec/19160-6.png
303
- - spec/19160-7.gif
304
- - spec/19160-8.jpg
305
- - spec/examples/header.html
306
- - spec/examples/rice.doc
307
- - spec/examples/rice.html
308
- - spec/examples/rice_images/rice_image1.gif
309
- - spec/examples/rice_images/rice_image1.png
310
- - spec/examples/rice_images/rice_image2.png
311
- - spec/examples/rice_images/rice_image3_1.png
312
- - spec/examples/rice_images/rice_image3_2.png
313
- - spec/examples/rice_images/rice_image3_3.png
314
- - spec/header.html
315
- - spec/header_img.html
316
- - spec/html2doc_spec.rb
317
- - spec/odf.svg
318
- - spec/spec_helper.rb
319
295
  homepage: https://github.com/metanorma/html2doc
320
296
  licenses:
321
297
  - CC-BY-SA-3.0
@@ -329,7 +305,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
329
305
  requirements:
330
306
  - - ">="
331
307
  - !ruby/object:Gem::Version
332
- version: 2.5.0
308
+ version: 2.7.0
333
309
  required_rubygems_version: !ruby/object:Gem::Requirement
334
310
  requirements:
335
311
  - - ">="
@@ -1,15 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: rake
4
-
5
- on:
6
- push:
7
- branches: [ master, main ]
8
- tags: [ v* ]
9
- pull_request:
10
-
11
- jobs:
12
- rake:
13
- uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14
- secrets:
15
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -1,24 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: release
4
-
5
- on:
6
- workflow_dispatch:
7
- inputs:
8
- next_version:
9
- description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
- required: true
12
- default: 'skip'
13
- push:
14
- tags: [ v* ]
15
-
16
- jobs:
17
- release:
18
- uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
- with:
20
- next_version: ${{ github.event.inputs.next_version }}
21
- secrets:
22
- rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
23
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
24
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "html2doc"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/html2doc DELETED
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "html2doc"
4
- require "optparse"
5
-
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: bin/html2doc filename [options]"
9
-
10
- opts.on("--stylesheet FILE.CSS", "Use the provided stylesheet") do |v|
11
- options[:stylesheet] = v
12
- end
13
- opts.on("--header HEADER.HTML", "Use the provided stylesheet") do |v|
14
- options[:header] = v
15
- end
16
- end.parse!
17
-
18
- if ARGV.length < 1
19
- puts "Usage: bin/html2doc filename [options]"
20
- exit
21
- end
22
-
23
- Html2Doc.process(
24
- filename: ARGV[0].gsub(/\.html?$/, ""),
25
- stylesheet: options[:stylesheet],
26
- header: options[:header],
27
- ).process(File.read(ARGV[0], encoding: "utf-8"))
data/bin/rspec DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
- "../../Gemfile", Pathname.new(__FILE__).realpath
12
- )
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("rspec-core", "rspec")
18
-
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/spec/19160-6.png DELETED
Binary file
data/spec/19160-7.gif DELETED
Binary file
data/spec/19160-8.jpg DELETED
Binary file
@@ -1,184 +0,0 @@
1
- <html xmlns:v="urn:schemas-microsoft-com:vml"
2
- xmlns:o="urn:schemas-microsoft-com:office:office"
3
- xmlns:w="urn:schemas-microsoft-com:office:word"
4
- xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
5
- xmlns:mv="http://macVmlSchemaUri" xmlns="http://www.w3.org/TR/REC-html40">
6
-
7
- <head>
8
- <meta name=Title content="">
9
- <meta name=Keywords content="">
10
- <meta http-equiv=Content-Type content="text/html; charset=utf-8">
11
- <meta name=ProgId content=Word.Document>
12
- <meta name=Generator content="Microsoft Word 15">
13
- <meta name=Originator content="Microsoft Word 15">
14
- <link id=Main-File rel=Main-File href="../rice.html">
15
- <!--[if gte mso 9]><xml>
16
- <o:shapedefaults v:ext="edit" spidmax="2049"/>
17
- </xml><![endif]-->
18
- </head>
19
-
20
- <body lang=EN link=blue vlink="#954F72">
21
-
22
- <div style='mso-element:footnote-separator' id=fs>
23
-
24
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
25
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
26
-
27
- <hr align=left size=1 width="33%">
28
-
29
- <![endif]></span></span></p>
30
-
31
- </div>
32
-
33
- <div style='mso-element:footnote-continuation-separator' id=fcs>
34
-
35
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
36
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
37
-
38
- <hr align=left size=1>
39
-
40
- <![endif]></span></span></p>
41
-
42
- </div>
43
-
44
- <div style='mso-element:endnote-separator' id=es>
45
-
46
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
47
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
48
-
49
- <hr align=left size=1 width="33%">
50
-
51
- <![endif]></span></span></p>
52
-
53
- </div>
54
-
55
- <div style='mso-element:endnote-continuation-separator' id=ecs>
56
-
57
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
58
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
59
-
60
- <hr align=left size=1>
61
-
62
- <![endif]></span></span></p>
63
-
64
- </div>
65
-
66
- <div style='mso-element:header' id=eh1>
67
-
68
- <p class=MsoHeader align=left style='text-align:left;line-height:12.0pt;
69
- mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&nbsp;CD 17301-1:2016(E)</span></p>
70
-
71
- </div>
72
-
73
- <div style='mso-element:header' id=h1>
74
-
75
- <p class=MsoHeader style='margin-bottom:18.0pt'><span lang=EN-GB
76
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-weight:normal'>©
77
- ISO/IEC&nbsp;2016&nbsp;– All rights reserved</span><span lang=EN-GB
78
- style='font-weight:normal'><o:p></o:p></span></p>
79
-
80
- </div>
81
-
82
- <div style='mso-element:footer' id=ef1>
83
-
84
- <p class=MsoFooter style='margin-top:12.0pt;line-height:12.0pt;mso-line-height-rule:
85
- exactly'><!--[if supportFields]><b style='mso-bidi-font-weight:normal'><span
86
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
87
- style='mso-element:field-begin'></span><span
88
- style='mso-spacerun:yes'> </span>PAGE<span style='mso-spacerun:yes'>  
89
- </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b
90
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
91
- mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>2</span></span></b><!--[if supportFields]><b
92
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
93
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
94
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
95
- style='mso-tab-count:1'>                                                                                                                                                                           </span>©
96
- ISO/IEC&nbsp;2016&nbsp;– All rights reserved<o:p></o:p></span></p>
97
-
98
- </div>
99
-
100
- <div style='mso-element:header' id=eh2>
101
-
102
- <p class=MsoHeader align=left style='text-align:left;line-height:12.0pt;
103
- mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&nbsp;CD 17301-1:2016(E)</span></p>
104
-
105
- </div>
106
-
107
- <div style='mso-element:header' id=h2>
108
-
109
- <p class=MsoHeader align=right style='text-align:right;line-height:12.0pt;
110
- mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&nbsp;CD 17301-1:2016(E)</span></p>
111
-
112
- </div>
113
-
114
- <div style='mso-element:footer' id=ef2>
115
-
116
- <p class=MsoFooter style='line-height:12.0pt;mso-line-height-rule:exactly'><!--[if supportFields]><span
117
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
118
- style='mso-element:field-begin'></span><span
119
- style='mso-spacerun:yes'> </span>PAGE<span style='mso-spacerun:yes'>  
120
- </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span
121
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
122
- style='mso-no-proof:yes'>ii</span></span><!--[if supportFields]><span
123
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
124
- style='mso-element:field-end'></span></span><![endif]--><span lang=EN-GB
125
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span style='mso-tab-count:
126
- 1'>                                                                                                                                                                           </span>©
127
- ISO/IEC&nbsp;2016&nbsp;– All rights reserved<o:p></o:p></span></p>
128
-
129
- </div>
130
-
131
- <div style='mso-element:footer' id=f2>
132
-
133
- <p class=MsoFooter style='line-height:12.0pt'><span lang=EN-GB
134
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'>© ISO/IEC&nbsp;2016&nbsp;– All
135
- rights reserved<span style='mso-tab-count:1'>                                                                                                                                                                          </span></span><!--[if supportFields]><span
136
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
137
- style='mso-element:field-begin'></span> PAGE<span style='mso-spacerun:yes'>  
138
- </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span
139
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
140
- style='mso-no-proof:yes'>iii</span></span><!--[if supportFields]><span
141
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
142
- style='mso-element:field-end'></span></span><![endif]--><span lang=EN-GB
143
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
144
-
145
- </div>
146
-
147
- <div style='mso-element:footer' id=ef3>
148
-
149
- <p class=MsoFooter style='margin-top:12.0pt;line-height:12.0pt;mso-line-height-rule:
150
- exactly'><!--[if supportFields]><b style='mso-bidi-font-weight:normal'><span
151
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
152
- style='mso-element:field-begin'></span><span
153
- style='mso-spacerun:yes'> </span>PAGE<span style='mso-spacerun:yes'>  
154
- </span>\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b
155
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
156
- mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>2</span></span></b><!--[if supportFields]><b
157
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
158
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
159
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
160
- style='mso-tab-count:1'>                                                                                                                                                                           </span>©
161
- ISO/IEC&nbsp;2016&nbsp;– All rights reserved<o:p></o:p></span></p>
162
-
163
- </div>
164
-
165
- <div style='mso-element:footer' id=f3>
166
-
167
- <p class=MsoFooter style='line-height:12.0pt'><span lang=EN-GB
168
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'>© ISO/IEC&nbsp;2016&nbsp;– All
169
- rights reserved<span style='mso-tab-count:1'>                                                                                                                                                                           </span></span><!--[if supportFields]><b
170
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
171
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-begin'></span>
172
- PAGE<span style='mso-spacerun:yes'>   </span>\* MERGEFORMAT <span
173
- style='mso-element:field-separator'></span></span></b><![endif]--><b
174
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
175
- mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>3</span></span></b><!--[if supportFields]><b
176
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
177
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
178
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
179
-
180
- </div>
181
-
182
- </body>
183
-
184
- </html>