prawn-markup 1.0.1 → 1.1.0

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: e4e901d1a82b9468866e3355cf84908e59b8ae60670b71334d76409e58253b4d
4
- data.tar.gz: 1cd88734f4a8e2f490c856b5c75478552c407b7e0757f5ff112277080fff0b2e
3
+ metadata.gz: 7d7d7fba33e7e87da6a9b6828a8dfdd0ea40be83eaf4564744f4b20e766a85b2
4
+ data.tar.gz: 2e7fdf53d140797d993f651320728ff42755371294c5fd501f2716f52111b443
5
5
  SHA512:
6
- metadata.gz: 44e4d67545a64fc93c9ab5f6c35cfd8d9d095adaed07b9a6b3f0f1d6da7ce15a17c4c0882930658cc087bc397a43414e23f090aca1141326854590556bacc797
7
- data.tar.gz: b7b2893c2f2d903bd79d6b02dff6d4e9ab338108952cdea4a1f1c18d8ad9682afe6eb249ce7ab044a4821c09cc94296f30c0e5dc7aae2b842a93effd42f09435
6
+ metadata.gz: a9f6ec2986e5e6fda0ad851689cdf6fa34d24a1b0a11656778613bd57e0937cab3dc082bd8bdc4c0e9f3713f5197010f84d5aa9ce6654cbfa6e5d7425d6c46cf
7
+ data.tar.gz: 76ae5a9dd1f544ab2164e4e4e56d805c71114b4772585dae07c532edbff92493c54e41a0a48fedc033112027e80516ba7322e2fe0e9e2a9182e3d015abf546cc
data/README.md CHANGED
@@ -69,7 +69,7 @@ doc.markup('<p>Hello World</p><hr/><p>KTHXBYE</p>', text: { align: :center })
69
69
 
70
70
  Options may be set for `text`, `heading[1-6]`, `table` (subkeys `cell` and `header`) and `list` (subkeys `content` and `bullet`).
71
71
 
72
- Text and heading options include all keys from Prawns [#text](http://prawnpdf.org/api-docs/2.0/Prawn/Text.html#text-instance_method) method: `font`, `size`, `color`, `style`, `align`, `valign`, `leading`,`direction`, `character_spacing`, `indent_paragraphs`, `kerning`, `mode`.
72
+ Text and heading options include all keys from Prawns [#text](https://prawnpdf.org/docs/prawn/2.5.0/Prawn/Text.html#text-instance_method) method: `font`, `size`, `color`, `style`, `align`, `valign`, `leading`,`direction`, `character_spacing`, `indent_paragraphs`, `kerning`, `mode`.
73
73
 
74
74
  Tables and lists are rendered with [prawn-table](https://github.com/prawnpdf/prawn-table) and have the following additional options: `padding`, `borders`, `border_width`, `border_color`, `background_color`, `border_lines`, `rotate`, `overflow`, `min_font_size`. Options from `text` may be overridden.
75
75
 
@@ -78,6 +78,7 @@ Beside these options handled by Prawn / prawn-table, the following values may be
78
78
  - `:text`
79
79
  - `:preprocessor`: A proc/callable that is called each time before a chunk of text is rendered.
80
80
  - `:margin_bottom`: Margin after each `<p>`, `<ol>`, `<ul>` or `<table>`. Defaults to about half a line.
81
+ - `:treat_empty_paragraph_as_new_line`: Boolean flag to set a new line if paragraph is empty.
81
82
  - `:heading1-6`
82
83
  - `:margin_top`: Margin before a heading. Default is 0.
83
84
  - `:margin_bottom`: Margin after a heading. Default is 0.
@@ -27,7 +27,7 @@ module Prawn
27
27
  end
28
28
 
29
29
  def text_options
30
- (options[:text] || {})
30
+ options[:text] || {}
31
31
  end
32
32
 
33
33
  def compute_image_width(hash, max_width)
@@ -133,7 +133,7 @@ module Prawn
133
133
  if width.nil? && total_width
134
134
  width = total_width - column_width_sum - ((columns_without_width - 1) * MIN_COL_WIDTH)
135
135
  end
136
- super(node, width, style_options)
136
+ super
137
137
  end
138
138
 
139
139
  def compute_column_widths
@@ -63,11 +63,11 @@ module Prawn
63
63
  def add_paragraph
64
64
  text = dump_text
65
65
  text.gsub!(/[^\n]/, '') if text.strip.empty?
66
- unless text.empty?
67
- add_bottom_margin
68
- add_formatted_text(text, text_options)
69
- put_bottom_margin(text_margin_bottom)
70
- end
66
+ return if text.empty? && !treat_empty_paragraph_as_new_line?
67
+
68
+ add_bottom_margin
69
+ add_formatted_text(text.empty? ? "\n" : text, text_options)
70
+ put_bottom_margin(text_margin_bottom)
71
71
  end
72
72
 
73
73
  def add_current_text(options = text_options)
@@ -151,6 +151,10 @@ module Prawn
151
151
  inline_format: true
152
152
  }
153
153
  end
154
+
155
+ def treat_empty_paragraph_as_new_line?
156
+ text_options[:treat_empty_paragraph_as_new_line] || false
157
+ end
154
158
  end
155
159
  end
156
160
  end
@@ -86,6 +86,10 @@ module Prawn
86
86
  def add_cell_text_node(cell, options = {})
87
87
  return unless buffered_text?
88
88
 
89
+ # only allow on supported options of prawn-table; See https://github.com/prawnpdf/prawn-table/blob/master/manual/table/cell_text.rb
90
+ options = options.slice(*%i[font font_style inline_format kerning leading min_font_size size
91
+ overflow rotate rotate_around single_line text_color valign])
92
+
89
93
  cell.nodes << options.merge(content: dump_text.strip)
90
94
  end
91
95
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module Markup
5
- VERSION = '1.0.1'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Zumkehr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-17 00:00:00.000000000 Z
11
+ date: 2025-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 3.5.22
219
+ rubygems_version: 3.4.10
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: Parse simple HTML markup to include in Prawn PDFs