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 +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/docxify/document.rb +10 -1
- data/lib/docxify/element/page_layout.rb +9 -0
- data/lib/docxify/element/paragraph.rb +7 -7
- data/lib/docxify/version.rb +1 -1
- 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: bc2de5623d8d0605d4aa0ad437c657749e0b39c91c13dc3af0bea385e75dabc3
|
4
|
+
data.tar.gz: 026160dfca1a977e7a8b7563e4268c363918f2130fe2e89dc0346037013d13ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
data/lib/docxify/document.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
parse_simple_html(@text)
|
25
|
+
else
|
26
|
+
[@text.gsub("<", "<").gsub(">", ">")]
|
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]
|
62
|
-
#{"<w:i/><w:iCs/>" if node.is_a?(Hash) && node[:tag]
|
63
|
-
#{"<w:u w:val=\"single\"/>" if node.is_a?(Hash) && (node[:tag]
|
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
|
data/lib/docxify/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|