Module: Prawn::Markup::Processor::Text
- Included in:
- Prawn::Markup::Processor
- Defined in:
- lib/prawn/markup/processor/text.rb
Class Method Summary collapse
Instance Method Summary collapse
- #append_color_tag(color) ⇒ Object
- #default_link_options ⇒ Object
- #end_a ⇒ Object (also: #end_link)
- #end_b ⇒ Object (also: #end_strong)
- #end_color ⇒ Object
- #end_font ⇒ Object
- #end_i ⇒ Object (also: #end_em)
- #end_strikethrough ⇒ Object (also: #end_s, #end_strike, #end_del)
- #end_sub ⇒ Object
- #end_sup ⇒ Object
- #end_u ⇒ Object
- #link_options ⇒ Object
- #start_a ⇒ Object (also: #start_link)
- #start_b ⇒ Object (also: #start_strong)
- #start_color ⇒ Object
- #start_font ⇒ Object
- #start_i ⇒ Object (also: #start_em)
- #start_strikethrough ⇒ Object (also: #start_s, #start_strike, #start_del)
- #start_sub ⇒ Object
- #start_sup ⇒ Object
- #start_u ⇒ Object
Class Method Details
.prepended(base) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/prawn/markup/processor/text.rb', line 6 def self.prepended(base) base.known_elements.push( 'a', 'b', 'strong', 'i', 'em', 'u', 'strikethrough', 'strike', 's', 'del', 'sub', 'sup', 'color', 'font' ) end |
Instance Method Details
#append_color_tag(color) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/prawn/markup/processor/text.rb', line 122 def append_color_tag(color) if color.is_a?(Array) c, m, y, k = color append_text("<color c=\"#{c}\" m=\"#{m}\" y=\"#{y}\" k=\"#{k}\">") else append_text("<color rgb=\"#{color}\">") end end |
#default_link_options ⇒ Object
31 32 33 34 35 36 |
# File 'lib/prawn/markup/processor/text.rb', line 31 def { color: nil, underline: false } end |
#end_a ⇒ Object Also known as: end_link
20 21 22 23 24 |
# File 'lib/prawn/markup/processor/text.rb', line 20 def end_a append_text('</link>') end_color if [:color] end_u if [:underline] end |
#end_b ⇒ Object Also known as: end_strong
43 44 45 |
# File 'lib/prawn/markup/processor/text.rb', line 43 def end_b append_text('</b>') end |
#end_color ⇒ Object
106 107 108 |
# File 'lib/prawn/markup/processor/text.rb', line 106 def end_color append_text('</color>') end |
#end_font ⇒ Object
118 119 120 |
# File 'lib/prawn/markup/processor/text.rb', line 118 def end_font append_text('</font>') end |
#end_i ⇒ Object Also known as: end_em
53 54 55 |
# File 'lib/prawn/markup/processor/text.rb', line 53 def end_i append_text('</i>') end |
#end_strikethrough ⇒ Object Also known as: end_s, end_strike, end_del
73 74 75 |
# File 'lib/prawn/markup/processor/text.rb', line 73 def end_strikethrough append_text('</strikethrough>') end |
#end_sub ⇒ Object
84 85 86 |
# File 'lib/prawn/markup/processor/text.rb', line 84 def end_sub append_text('</sub>') end |
#end_sup ⇒ Object
92 93 94 |
# File 'lib/prawn/markup/processor/text.rb', line 92 def end_sup append_text('</sup>') end |
#end_u ⇒ Object
62 63 64 |
# File 'lib/prawn/markup/processor/text.rb', line 62 def end_u append_text('</u>') end |
#link_options ⇒ Object
27 28 29 |
# File 'lib/prawn/markup/processor/text.rb', line 27 def ||= HashMerger.deep(, [:link] || {}) end |
#start_a ⇒ Object Also known as: start_link
13 14 15 16 17 |
# File 'lib/prawn/markup/processor/text.rb', line 13 def start_a start_u if [:underline] append_color_tag([:color]) if [:color] append_text("<link href=\"#{current_attrs['href']}\">") end |
#start_b ⇒ Object Also known as: start_strong
38 39 40 |
# File 'lib/prawn/markup/processor/text.rb', line 38 def start_b append_text('<b>') end |
#start_color ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'lib/prawn/markup/processor/text.rb', line 96 def start_color rgb, c, m, y, k = current_attrs.values_at('rgb', 'c', 'm', 'y', 'k') if [c, m, y, k].all? append_color_tag([c, m, y, k]) else append_color_tag(rgb) end end |
#start_font ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/prawn/markup/processor/text.rb', line 110 def start_font font_attrs = current_attrs .slice('size', 'name', 'character_spacing') .reduce('') { |acc, (key, val)| "#{acc} #{key}=\"#{val}\"" } append_text("<font #{font_attrs}>") end |
#start_i ⇒ Object Also known as: start_em
48 49 50 |
# File 'lib/prawn/markup/processor/text.rb', line 48 def start_i append_text('<i>') end |
#start_strikethrough ⇒ Object Also known as: start_s, start_strike, start_del
66 67 68 |
# File 'lib/prawn/markup/processor/text.rb', line 66 def start_strikethrough append_text('<strikethrough>') end |
#start_sub ⇒ Object
80 81 82 |
# File 'lib/prawn/markup/processor/text.rb', line 80 def start_sub append_text('<sub>') end |
#start_sup ⇒ Object
88 89 90 |
# File 'lib/prawn/markup/processor/text.rb', line 88 def start_sup append_text('<sup>') end |
#start_u ⇒ Object
58 59 60 |
# File 'lib/prawn/markup/processor/text.rb', line 58 def start_u append_text('<u>') end |