docxify 0.0.9 → 0.1.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: c43501f65a265d3e8ce49ae0c5081d425c838465e31392b8e17c66c5d32214f9
4
- data.tar.gz: efff6888d11c6ba8d9984150c0589d57e960b0e04fdc3daa79a2a458517b0fdd
3
+ metadata.gz: bc2de5623d8d0605d4aa0ad437c657749e0b39c91c13dc3af0bea385e75dabc3
4
+ data.tar.gz: 026160dfca1a977e7a8b7563e4268c363918f2130fe2e89dc0346037013d13ef
5
5
  SHA512:
6
- metadata.gz: c8dae5642665518f3c8be12d9a3d16a54ab626e3601b0b1073583f5c6f67cc80e31215e045f9ce593e520db7e35349d55363fee1f4713be4bb8eb7a704081780
7
- data.tar.gz: 2d6aca43dba5dbe008f58e83a7bac426d6edb43aac83ba9812dc3eb1ab9bbe9218d128f88d6dfbd78fafaef38f8be32b1a97a47ba1519d13f4c86b81417c62c7
6
+ metadata.gz: 41d3b81b2ef6e3f90a1cc9a0149b19f93b96f86bb581d0c83a7f739d55cac24bae6337871a70c7278039f46ca50ecd164525d3b2f9631a7e329d1bd2e3a54989
7
+ data.tar.gz: eca5c4a3eeb6855546fb7584605fc6579c8cfbe6a31014b1d0dd9896da9c6e15482c34b2638a98c6bca6d6ca887f0f12c076d71018af6f52bcc1421ba03e5ff1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.1
4
+
5
+ Features:
6
+
7
+ - Allow combining bold, italic and underline on a single element (thanks to @b0nn1e for the PR)
8
+
9
+ ## 0.1.0
10
+
11
+ Features:
12
+
13
+ - Implemented Document#bounds_width and Document#bounds_height
14
+
15
+ ## 0.0.9
16
+
17
+ Features:
18
+
19
+ - Fixed page layout loading
20
+
3
21
  ## 0.0.8
4
22
 
5
23
  Features:
@@ -16,6 +16,14 @@ module DocXify
16
16
  @margins = { top: 2, bottom: 2, left: 2, right: 2 }.merge(options[:margins] || {})
17
17
  end
18
18
 
19
+ def bounds_width
20
+ @page_layout&.bounds_width || (@width - @margins[:left] - @margins[:right])
21
+ end
22
+
23
+ def bounds_height
24
+ @page_layout&.bounds_height || (@height - @margins[:top] - @margins[:bottom])
25
+ end
26
+
19
27
  def default_styling(options = {})
20
28
  @font = options[:font] if options[:font]
21
29
  @size = options[:size] if options[:size]
@@ -89,7 +97,8 @@ module DocXify
89
97
 
90
98
  def add_page_layout(options = {})
91
99
  options[:document] = self
92
- add DocXify::Element::PageLayout.new(options)
100
+ @page_layout = DocXify::Element::PageLayout.new(options)
101
+ add @page_layout
93
102
  end
94
103
 
95
104
  def add_divider
@@ -15,6 +15,15 @@ module DocXify
15
15
  @orientation = options[:orientation] || :portrait
16
16
  end
17
17
 
18
+ # Don't consider this part of the public API, they're used by Document if it's been created
19
+ def bounds_width
20
+ @width - @margins[:left] - @margins[:right]
21
+ end
22
+
23
+ def bounds_height
24
+ @height - @margins[:top] - @margins[:bottom]
25
+ end
26
+
18
27
  def to_s(_container = nil)
19
28
  <<~XML
20
29
  <w:p>
@@ -21,10 +21,10 @@ module DocXify
21
21
 
22
22
  def to_s(_container = nil)
23
23
  nodes = if @inline_styling
24
- parse_simple_html(@text)
25
- else
26
- [@text.gsub("<", "&lt;").gsub(">", "&gt;")]
27
- end
24
+ parse_simple_html(@text)
25
+ else
26
+ [@text.gsub("<", "&lt;").gsub(">", "&gt;")]
27
+ end
28
28
 
29
29
  xml = "<w:p>"
30
30
 
@@ -58,9 +58,9 @@ module DocXify
58
58
  <w:sz w:val="#{DocXify.pt2halfpt(@size)}"/>
59
59
  <w:szCs w:val="#{DocXify.pt2halfpt(@size)}"/>
60
60
  #{"<w:highlight w:val=\"yellow\"/>" if @highlight}
61
- #{"<w:b/><w:bCs/>" if node.is_a?(Hash) && node[:tag] == "b"}
62
- #{"<w:i/><w:iCs/>" if node.is_a?(Hash) && node[:tag] == "i"}
63
- #{"<w:u w:val=\"single\"/>" if node.is_a?(Hash) && (node[:tag] == "u" || node[:tag] == "a")}
61
+ #{"<w:b/><w:bCs/>" if node.is_a?(Hash) && node[:tag].match?("b")}
62
+ #{"<w:i/><w:iCs/>" if node.is_a?(Hash) && node[:tag].match?("i")}
63
+ #{"<w:u w:val=\"single\"/>" if node.is_a?(Hash) && (node[:tag].match?("u") || node[:tag] == "a")}
64
64
  #{"<w:rStyle w:val=\"Hyperlink\"/>" if node.is_a?(Hash) && node[:tag] == "a"}
65
65
  </w:rPr>
66
66
  XML
@@ -1,3 +1,3 @@
1
1
  module DocXify
2
- VERSION = "0.0.9".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docxify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-23 00:00:00.000000000 Z
11
+ date: 2024-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip