docxify 0.1.7 → 0.1.8
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 +6 -0
- data/README.md +1 -1
- data/lib/docxify/container.rb +1 -1
- data/lib/docxify/document.rb +1 -1
- data/lib/docxify/element/base.rb +7 -7
- data/lib/docxify/element/image.rb +1 -1
- data/lib/docxify/element/paragraph.rb +1 -1
- data/lib/docxify/element/table.rb +4 -4
- data/lib/docxify/element/table_cell.rb +6 -2
- data/lib/docxify/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2001fd538f53baaa855da323413656be06af5c3d6ad55c662a27cda494e03d8b
|
|
4
|
+
data.tar.gz: ca1ade585eb4a3e662362d7909daf2026f6069e7ede204be165fec2f542ac6a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1dcbd60cdd20008d7f3ae06d624024d7d236ef3740e8c7b86f4a6dee052e23bb5f1a4431ef3c2c0eb4005b0b73ce1d731995f30da534778ce9ad93ad798142b
|
|
7
|
+
data.tar.gz: fec075ad3e35e7cd0d8c3d449d758d06174762734e56f2365b80d829e9dff48708c12152d253dc11d6187e779e76c71b795bc0deb5c60380a7c6299d34645471
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -31,7 +31,7 @@ gem install docxify
|
|
|
31
31
|
@docx.add_paragraph "Highlighted text", background: "#FFFF99"
|
|
32
32
|
@docx.add_paragraph "This won't show as <b>bold</b>", inline_styling: false
|
|
33
33
|
|
|
34
|
-
@docx.add_paragraph "\t1.1.1\tBody copy", tab_stops_cm: [1, 2]
|
|
34
|
+
@docx.add_paragraph "\t1.1.1\tBody copy", tab_stops_cm: [1, 2], hanging_cm: 2
|
|
35
35
|
@docx.add_paragraph "{CHECKBOX_EMPTY}\tEmpty checkbox", tab_stops_cm: [2]
|
|
36
36
|
@docx.add_paragraph "{CHECKBOX_CHECKED}\tChecked checkbox", tab_stops_cm: [2]
|
|
37
37
|
|
data/lib/docxify/container.rb
CHANGED
|
@@ -56,7 +56,7 @@ module DocXify
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def document_xml_rels
|
|
59
|
-
xml =
|
|
59
|
+
xml = +<<~XML
|
|
60
60
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
61
61
|
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
62
62
|
<Relationship Id="rId3" Target="webSettings.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"/>
|
data/lib/docxify/document.rb
CHANGED
|
@@ -44,7 +44,7 @@ module DocXify
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def build_xml(container)
|
|
47
|
-
xml =
|
|
47
|
+
xml = +<<~XML
|
|
48
48
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49
49
|
<w:document mc:Ignorable="w14 w15 w16se w16cid w16 w16cex w16sdtdh w16du wp14" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:oel="http://schemas.microsoft.com/office/2019/extlst" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16="http://schemas.microsoft.com/office/word/2018/wordml" xmlns:w16cex="http://schemas.microsoft.com/office/word/2018/wordml/cex" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16du="http://schemas.microsoft.com/office/word/2023/wordml/word16du" xmlns:w16sdtdh="http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape">
|
|
50
50
|
<w:body>
|
data/lib/docxify/element/base.rb
CHANGED
|
@@ -9,10 +9,10 @@ module DocXify
|
|
|
9
9
|
|
|
10
10
|
def parse_simple_html(html)
|
|
11
11
|
state = :text
|
|
12
|
-
tag = ""
|
|
13
|
-
content = ""
|
|
12
|
+
tag = +""
|
|
13
|
+
content = +""
|
|
14
14
|
result = []
|
|
15
|
-
text = ""
|
|
15
|
+
text = +""
|
|
16
16
|
last_char = ""
|
|
17
17
|
|
|
18
18
|
html.each_char do |char|
|
|
@@ -21,16 +21,16 @@ module DocXify
|
|
|
21
21
|
when :text # This is a text node, not part of an HTML tag
|
|
22
22
|
if char == "<"
|
|
23
23
|
state = :tag
|
|
24
|
-
tag = ""
|
|
24
|
+
tag = +""
|
|
25
25
|
result << text unless text.empty?
|
|
26
|
-
text = ""
|
|
26
|
+
text = +""
|
|
27
27
|
else
|
|
28
28
|
text << char
|
|
29
29
|
end
|
|
30
30
|
when :tag # Within an HTML tag itself
|
|
31
31
|
if char == ">"
|
|
32
32
|
state = :content
|
|
33
|
-
content = ""
|
|
33
|
+
content = +""
|
|
34
34
|
tag_name, *attributes = tag.split
|
|
35
35
|
tag_name.gsub!(/\s*\//, "")
|
|
36
36
|
attributes.delete_if { |attr| attr == "/" }
|
|
@@ -62,7 +62,7 @@ module DocXify
|
|
|
62
62
|
if char == "<"
|
|
63
63
|
state = :tag
|
|
64
64
|
result.last[:content] = content
|
|
65
|
-
content = ""
|
|
65
|
+
content = +""
|
|
66
66
|
else
|
|
67
67
|
content << char
|
|
68
68
|
end
|
|
@@ -28,7 +28,7 @@ module DocXify
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def to_s(_container = nil)
|
|
31
|
-
xml = ""
|
|
31
|
+
xml = +""
|
|
32
32
|
xml << table_element_start
|
|
33
33
|
xml << table_properties
|
|
34
34
|
xml << table_grid
|
|
@@ -44,7 +44,7 @@ module DocXify
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def table_properties
|
|
47
|
-
xml = ""
|
|
47
|
+
xml = +""
|
|
48
48
|
xml << "<w:tblPr>"
|
|
49
49
|
xml << '<w:tblStyle w:val="TableGrid"/>'
|
|
50
50
|
xml << '<w:tblW w:type="auto" w:w="0"/>'
|
|
@@ -63,7 +63,7 @@ module DocXify
|
|
|
63
63
|
default_equal_width = (@document.width / @rows.first.size).to_i
|
|
64
64
|
|
|
65
65
|
@column_widths = []
|
|
66
|
-
xml = "<w:tblGrid>"
|
|
66
|
+
xml = +"<w:tblGrid>"
|
|
67
67
|
@rows.first.each do |cell|
|
|
68
68
|
width = if cell.width_cm
|
|
69
69
|
DocXify.cm2dxa(cell.width_cm)
|
|
@@ -79,7 +79,7 @@ module DocXify
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def table_row(row)
|
|
82
|
-
xml = "<w:tr>"
|
|
82
|
+
xml = +"<w:tr>"
|
|
83
83
|
widths = @column_widths.dup
|
|
84
84
|
row.each do |cell|
|
|
85
85
|
if cell.nil?
|
|
@@ -6,7 +6,7 @@ module DocXify
|
|
|
6
6
|
def initialize(content, options = {})
|
|
7
7
|
super()
|
|
8
8
|
@content = content
|
|
9
|
-
@valign = options[:valign] || :top
|
|
9
|
+
@valign = (options[:valign] if %i[top center bottom].include?(options[:valign])) || :top
|
|
10
10
|
@align = options[:align] || :left
|
|
11
11
|
@nowrap = options[:nowrap]
|
|
12
12
|
@colspan = options[:colspan]
|
|
@@ -15,11 +15,15 @@ module DocXify
|
|
|
15
15
|
@font = options[:font]
|
|
16
16
|
@size = options[:size]
|
|
17
17
|
@color = options[:color]
|
|
18
|
+
|
|
18
19
|
@borders = options[:borders]&.map(&:to_sym) || []
|
|
20
|
+
if @borders.include?(:all)
|
|
21
|
+
@borders = %i[top bottom left right]
|
|
22
|
+
end
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
def to_s
|
|
22
|
-
xml = "<w:tc>"
|
|
26
|
+
xml = +"<w:tc>"
|
|
23
27
|
xml << "<w:tcPr>"
|
|
24
28
|
xml << %Q(<w:tcW w:type="dxa" w:w="#{DocXify.cm2dxa(@width_cm)}"/>)
|
|
25
29
|
if !@colspan.nil? && @colspan.to_i > 1
|
data/lib/docxify/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: docxify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Jeffries
|
|
8
8
|
- FounderCatalyst Ltd
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: exe
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: image_size
|
|
@@ -75,7 +74,6 @@ metadata:
|
|
|
75
74
|
source_code_uri: https://github.com/foundercatalyst/docxify
|
|
76
75
|
changelog_uri: https://github.com/foundercatalyst/docxify/CHANGELOG.md
|
|
77
76
|
rubygems_mfa_required: 'true'
|
|
78
|
-
post_install_message:
|
|
79
77
|
rdoc_options: []
|
|
80
78
|
require_paths:
|
|
81
79
|
- lib
|
|
@@ -90,8 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
90
88
|
- !ruby/object:Gem::Version
|
|
91
89
|
version: '0'
|
|
92
90
|
requirements: []
|
|
93
|
-
rubygems_version:
|
|
94
|
-
signing_key:
|
|
91
|
+
rubygems_version: 4.0.6
|
|
95
92
|
specification_version: 4
|
|
96
93
|
summary: DocXify is a gem to help you generate Word documents from Ruby.
|
|
97
94
|
test_files: []
|