html2doc 1.10.0 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9ef55b2a805994f5ca26253285cdc062ff7d9a16c12ce009935956513d3eb3c
4
- data.tar.gz: 8229037b442e8c9fd93790b14ec25daff760b4f98697b787da2ae8daef344699
3
+ metadata.gz: ec617237a616948fc0d46e624845dcc144a773e04cde204fee8e795dd0bb1c60
4
+ data.tar.gz: 763ab17d11cd59c7f0cad2878a84fb30cd312877896912cf30025a1ccc4db060
5
5
  SHA512:
6
- metadata.gz: 293dcfb6a88743f5a3a5e8bc7042d3a5f7c1e7f93683b22d21153591f2e82fdae5d3bb2c446817b2a06372469db09554078e2c5a804ff54cf2ba4ee54706e0bf
7
- data.tar.gz: 4bfac10267769fecca5b85fe68319bf17fce9ed021e6c1534cf7d76cee34193468919f3d4e1f9114257884d09661d8502a7a0f1de06ab05586842c360a4a7228
6
+ metadata.gz: 29105bd6bf8f151cafbff331f9eb8c9b225a0a203424bd02525ad700abb39f27fccd502dfb9306f6cf670751c8af27a28657dc32b3b8edde0c70543379ed2fd2
7
+ data.tar.gz: a57f0972562c7f2f766b7a91c5a7a522e18b8f876981301c34e8491812e2413ad6827b79a9e604a1c1cf985741c5e31754896ef77192dedb29f77396352bec66
data/README.adoc CHANGED
@@ -4,7 +4,7 @@ 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
6
  image:https://github.com/metanorma/html2doc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/html2doc/actions?workflow=rake"]
7
- image:https://codeclimate.com/github/metanorma/html2doc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/html2doc"]
7
+ // image:https://codeclimate.com/github/metanorma/html2doc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/html2doc"]
8
8
  image:https://img.shields.io/github/issues-pr-raw/metanorma/html2doc.svg["Pull Requests", link="https://github.com/metanorma/html2doc/pulls"]
9
9
  image:https://img.shields.io/github/commits-since/metanorma/html2doc/latest.svg["Commits since latest",link="https://github.com/metanorma/html2doc/releases"]
10
10
 
data/lib/html2doc/mime.rb CHANGED
@@ -90,22 +90,36 @@ class Html2Doc
90
90
  %r{^([A-Z]:)?/}.match?(src) ? src : File.join(localdir, src)
91
91
  end
92
92
 
93
+ IMAGE_IMAGEDATA =
94
+ ".//*[local-name() = 'img' or local-name() = 'imagedata']".freeze
95
+
93
96
  # only processes locally stored images
94
97
  def image_cleanup(docxml, dir, localdir)
95
98
  maxheight, maxwidth = page_dimensions(docxml)
96
- docxml.traverse do |i|
99
+ docxml.xpath(IMAGE_IMAGEDATA).each do |i|
97
100
  skip_image_cleanup?(i) and next
98
101
  local_filename = rename_image(i, dir, localdir)
99
- i["width"], i["height"] =
100
- if landscape?(i)
101
- Vectory.image_resize(i, local_filename, maxwidth, maxheight)
102
- else
103
- Vectory.image_resize(i, local_filename, maxheight, maxwidth)
104
- end
102
+ if tr_ancestor = i.xpath("ancestor::*[local-name() = 'tr']").first
103
+ image_count = tr_ancestor.xpath(IMAGE_IMAGEDATA).count
104
+ image_resize(i, local_filename, maxheight, maxwidth, image_count)
105
+ else # Normal behavior for non-table images
106
+ image_resize(i, local_filename, maxheight, maxwidth, 1)
107
+ end
105
108
  end
106
109
  docxml
107
110
  end
108
111
 
112
+ def image_resize(img, local_filename, maxheight, maxwidth, image_count)
113
+ img["width"], img["height"] =
114
+ if landscape?(img)
115
+ Vectory.image_resize(img, local_filename, maxwidth,
116
+ maxheight / image_count)
117
+ else
118
+ Vectory.image_resize(img, local_filename, maxheight,
119
+ maxwidth / image_count)
120
+ end
121
+ end
122
+
109
123
  def landscape?(img)
110
124
  img.ancestors.each do |a|
111
125
  a.name == "div" or next
@@ -1,3 +1,3 @@
1
1
  class Html2Doc
2
- VERSION = "1.10.0".freeze
2
+ VERSION = "1.10.1".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.10.0
4
+ version: 1.10.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: 2025-07-02 00:00:00.000000000 Z
11
+ date: 2025-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64