docxify 0.1.6 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '078327d60105c81b5d2408dc41a12f8938fc99ef39fc813e5313913b4fb85fe8'
4
- data.tar.gz: 8a96ec54548b34768e3480db12349ed9301c5fbc0f3f5b5f470b2788805541a0
3
+ metadata.gz: 2001fd538f53baaa855da323413656be06af5c3d6ad55c662a27cda494e03d8b
4
+ data.tar.gz: ca1ade585eb4a3e662362d7909daf2026f6069e7ede204be165fec2f542ac6a4
5
5
  SHA512:
6
- metadata.gz: 7891e352135d11bba98851c99733afece051a37fb283d2f576179dfd66a1a0da6e8656cd0b2d1885389b448baff183194cb0ce3e0599d468330f5b6981f4619f
7
- data.tar.gz: 28098adcc6b17ca39f67c15a5dacfe63c5d1d453bd19da781b0124b9398fb534fdeae8f78597c36372aa5f2b4103e961553474c9ea14783be9a86d7161a27400
6
+ metadata.gz: d1dcbd60cdd20008d7f3ae06d624024d7d236ef3740e8c7b86f4a6dee052e23bb5f1a4431ef3c2c0eb4005b0b73ce1d731995f30da534778ce9ad93ad798142b
7
+ data.tar.gz: fec075ad3e35e7cd0d8c3d449d758d06174762734e56f2365b80d829e9dff48708c12152d253dc11d6187e779e76c71b795bc0deb5c60380a7c6299d34645471
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.8
4
+
5
+ Bugfix:
6
+
7
+ - Fix FrozenError when used with `--enable=frozen-string-literal` (RUBYOPT); all mutable string accumulators now initialised with `+""` or `+<<~HEREDOC`
8
+
9
+ ## 0.1.7
10
+
11
+ Feature:
12
+
13
+ - Add ability to inline highlight parts
14
+
3
15
  ## 0.1.6
4
16
 
5
17
  Bugfix:
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
 
@@ -56,7 +56,7 @@ module DocXify
56
56
  end
57
57
 
58
58
  def document_xml_rels
59
- xml = <<~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"/>
@@ -44,7 +44,7 @@ module DocXify
44
44
  end
45
45
 
46
46
  def build_xml(container)
47
- xml = <<~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>
@@ -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
@@ -37,7 +37,7 @@ module DocXify
37
37
  end
38
38
 
39
39
  def to_s(_container = nil)
40
- xml = "<w:p>"
40
+ xml = +"<w:p>"
41
41
 
42
42
  xml << "<w:pPr>"
43
43
  if @align == :right
@@ -27,7 +27,7 @@ module DocXify
27
27
  [@text.gsub("<", "&lt;").gsub(">", "&gt;")]
28
28
  end
29
29
 
30
- xml = "<w:p>"
30
+ xml = +"<w:p>"
31
31
 
32
32
  xml << "<w:pPr>"
33
33
  xml << "<w:jc w:val=\"#{@align}\"/>" if @align != :left
@@ -59,7 +59,7 @@ module DocXify
59
59
  <w:color w:val="#{@color.gsub("#", "")}"/>
60
60
  <w:sz w:val="#{DocXify.pt2halfpt(@size)}"/>
61
61
  <w:szCs w:val="#{DocXify.pt2halfpt(@size)}"/>
62
- #{"<w:highlight w:val=\"yellow\"/>" if @highlight}
62
+ #{"<w:highlight w:val=\"yellow\"/>" if @highlight || (node.is_a?(Hash) && node[:tag].match?("mark"))}
63
63
  #{"<w:b/><w:bCs/>" if node.is_a?(Hash) && node[:tag].match?("b")}
64
64
  #{"<w:i/><w:iCs/>" if node.is_a?(Hash) && node[:tag].match?("i")}
65
65
  #{"<w:u w:val=\"single\"/>" if node.is_a?(Hash) && (node[:tag].match?("u") || node[:tag] == "a")}
@@ -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
@@ -1,3 +1,3 @@
1
1
  module DocXify
2
- VERSION = "0.1.6".freeze
2
+ VERSION = "0.1.8".freeze
3
3
  end
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.6
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: 2025-03-14 00:00:00.000000000 Z
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: 3.5.21
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: []