Module: RedCloth::Formatters::HTML
  
  
  
  
  
  
  
  
  
      - Includes:
 
      - Base
 
  
  
  
  
  
  
    - Defined in:
 
    - lib/redcloth/formatters/html.rb
 
  
  
 
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods included from Base
  #ignore, #inline_redcloth_version, #redcloth_version
  Dynamic Method Handling
  
    This class handles dynamic methods through the method_missing method
    
      in the class RedCloth::Formatters::Base
    
  
  
 
  
    Instance Method Details
    
      
  
  
    #acronym(opts)  ⇒ Object 
  
  
  
  
    
      
21
22
23
24 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 21
def acronym(opts)
  opts[:block] = true
  "<acronym#{pba(opts)}>#{caps(:text => opts[:text])}</acronym>"
end
     | 
  
 
    
      
  
  
    #amp(opts)  ⇒ Object 
  
  
  
  
    
      
207
208
209 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 207
def amp(opts)
  "&"
end 
     | 
  
 
    
      
  
  
    #apos(opts)  ⇒ Object 
  
  
  
  
    
      
235
236
237 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 235
def apos(opts)
  "'"
end 
     | 
  
 
    
      
  
  
    #arrow(opts)  ⇒ Object 
  
  
  
  
    
      
180
181
182 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 180
def arrow(opts)
  "→"
end 
     | 
  
 
    
      
  
  
    #auto_link(opts)  ⇒ Object 
  
  
  
  
    
      
123
124
125
126
127
128
129
130 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 123
def auto_link(opts)
  return opts[:href] unless auto_link_urls
  href_with_proto = opts[:href]
  href_with_proto = 'http://' + href_with_proto unless href_with_proto.index('http') == 0
  text = opts[:href]
  text = truncate(text[0, text.length - 6] + text[-5,3].replace("...") + text[-2..-1], 50)
  "<a href=\"#{escape_attribute href_with_proto}\">#{escape_attribute text}</a>"
end
     | 
  
 
    
      
  
  
    #bc_close(opts)  ⇒ Object 
  
  
  
  
    
      
99
100
101 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 99
def bc_close(opts)
  "</pre>\n"
end 
     | 
  
 
    
      
  
  
    #bc_open(opts)  ⇒ Object 
  
  
  
  
    
      
94
95
96
97 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 94
def bc_open(opts)
  opts[:block] = true
  "<pre#{pba(opts)}>"
end
     | 
  
 
    
      
  
  
    #bq_close(opts)  ⇒ Object 
  
  
  
  
    
      
109
110
111 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 109
def bq_close(opts)
  "</blockquote>\n"
end 
     | 
  
 
    
      
  
  
    #bq_open(opts)  ⇒ Object 
  
  
  
  
    
      
103
104
105
106
107 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 103
def bq_open(opts)
  opts[:block] = true
  cite = opts[:cite] ? " cite=\"#{ escape_attribute opts[:cite] }\"" : ''
  "<blockquote#{cite}#{pba(opts)}>\n"
end
     | 
  
 
    
      
  
  
    #br(opts)  ⇒ Object 
  
  
  
  
    
      
219
220
221
222
223
224
225 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 219
def br(opts)
  if hard_breaks == false
    "\n"
  else
    "<br#{pba(opts)} />\n"
  end
end
     | 
  
 
    
      
  
  
    #caps(opts)  ⇒ Object 
  
  
  
  
    
      
26
27
28
29
30
31
32
33 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 26
def caps(opts)
  if no_span_caps
    opts[:text]
  else
    opts[:class] = 'caps'
    span(opts)
  end
end
     | 
  
 
    
      
  
  
    #copyright(opts)  ⇒ Object 
  
  
  
  
    
      
199
200
201 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 199
def copyright(opts)
  "©"
end 
     | 
  
 
    
      
  
  
    #del(opts)  ⇒ Object 
  
  
  
  
    
      
35
36
37
38 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 35
def del(opts)
  opts[:block] = true
  "<del#{pba(opts)}>#{opts[:text]}</del>"
end
     | 
  
 
    
      
  
  
    #dim(opts)  ⇒ Object 
  
  
  
  
    
      
184
185
186
187
188
189 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 184
def dim(opts)
  opts[:text].gsub!('x', '×')
  opts[:text].gsub!("'", '′')
  opts[:text].gsub!('"', '″')
  opts[:text]
end
     | 
  
 
    
      
  
  
    #dl_close(opts = nil)  ⇒ Object 
  
  
  
  
    
      
63
64
65 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 63
def dl_close(opts=nil)
  "</dl>\n"
end 
     | 
  
 
    
      
  
  
    #dl_open(opts)  ⇒ Object 
  
  
  
  
    
      
58
59
60
61 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 58
def dl_open(opts)
  opts[:block] = true
  "<dl#{pba(opts)}>\n"
end
     | 
  
 
    
      
  
  
    #ellipsis(opts)  ⇒ Object 
  
  
  
  
    
      
168
169
170 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 168
def ellipsis(opts)
  "#{opts[:text]}…"
end
     | 
  
 
    
      
  
  
    #emdash(opts)  ⇒ Object 
  
  
  
  
    
      
172
173
174 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 172
def emdash(opts)
  "—"
end 
     | 
  
 
    
      
  
  
    #endash(opts)  ⇒ Object 
  
  
  
  
    
      
176
177
178 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 176
def endash(opts)
  " – "
end 
     | 
  
 
    
      
  
  
    #entity(opts)  ⇒ Object 
  
  
  
  
    
      
203
204
205 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 203
def entity(opts)
  "&#{opts[:text]};"
end
     | 
  
 
    
      
  
  
    #fn(opts)  ⇒ Object 
  
  
  
  
    
      
145
146
147
148
149
150 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 145
def fn(opts)
  no = opts[:id]
  opts[:id] = "fn#{no}"
  opts[:class] = ["footnote", opts[:class]].compact.join(" ")
  "<p#{pba(opts)}><a href=\"#fnr#{no}\"><sup>#{no}</sup></a> #{opts[:text]}</p>\n"
end
     | 
  
 
    
      
  
  
    
      
140
141
142
143 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 140
def (opts)
  opts[:id] ||= opts[:text]
  %Q{<sup class="footnote" id=\"fnr#{opts[:id]}\"><a href=\"#fn#{opts[:id]}\">#{opts[:text]}</a></sup>}
end
     | 
  
 
    
      
  
  
    #gt(opts)  ⇒ Object 
  
  
  
  
    
      
211
212
213 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 211
def gt(opts)
  ">"
end 
     | 
  
 
    
      
  
  
    #hr(opts)  ⇒ Object 
  
  
  
  
    
      
17
18
19 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 17
def hr(opts)
  "<hr#{pba(opts)} />\n"
end
     | 
  
 
    
      
  
  
    #html(opts)  ⇒ Object 
  
  
  
  
    
      
239
240
241 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 239
def html(opts)
  "#{opts[:text]}\n"
end
     | 
  
 
    
      
  
  
    #html_block(opts)  ⇒ Object 
  
  
  
  
    
      
243
244
245
246
247 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 243
def html_block(opts)
  inline_html(:text => "#{opts[:indent_before_start]}#{opts[:start_tag]}#{opts[:indent_after_start]}") + 
  "#{opts[:text]}" +
  inline_html(:text => "#{opts[:indent_before_end]}#{opts[:end_tag]}#{opts[:indent_after_end]}")
end
     | 
  
 
    
      
  
  
    #ignored_line(opts)  ⇒ Object 
  
  
  
  
    
      
265
266
267 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 265
def ignored_line(opts)
  opts[:text] + "\n"
end 
     | 
  
 
    
      
  
  
    #image(opts)  ⇒ Object 
  
  
  
  
    
      
132
133
134
135
136
137
138 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 132
def image(opts)
  opts.delete(:align)
  opts[:alt] = opts[:title]
  img = "<img src=\"#{escape_attribute opts[:src]}\"#{pba(opts)} alt=\"#{escape_attribute opts[:alt].to_s}\" />"  
  img = "<a href=\"#{escape_attribute opts[:href]}\">#{img}</a>" if opts[:href]
  img
end
     | 
  
 
    
      
  
  
    #inline_html(opts)  ⇒ Object 
  
  
  
  
    
      
257
258
259
260
261
262
263 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 257
def inline_html(opts)
  if filter_html
    html_esc(opts[:text], :html_escape_preformatted)
  else
    "#{opts[:text]}"   end
end
     | 
  
 
    
      
  
  
    #li_close(opts = nil)  ⇒ Object 
  
  
  
  
    
      
54
55
56 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 54
def li_close(opts=nil)
  "</li>\n"
end 
     | 
  
 
    
      
  
  
    #li_open(opts)  ⇒ Object 
  
  
  
  
    
      
50
51
52 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 50
def li_open(opts)
  "#{"\t" * opts[:nest]}<li#{pba(opts)}>#{opts[:text]}"
end
     | 
  
 
    
      
  
  
    #link(opts)  ⇒ Object 
  
  
  
  
    
      
113
114
115 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 113
def link(opts)
  "<a href=\"#{escape_attribute opts[:href]}\"#{pba(opts)}>#{opts[:name]}</a>"
end
     | 
  
 
    
      
  
  
    #lt(opts)  ⇒ Object 
  
  
  
  
    
      
215
216
217 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 215
def lt(opts)
  "<"
end 
     | 
  
 
    
      
  
  
    #multi_paragraph_quote(opts)  ⇒ Object 
  
  
  
  
    
      
164
165
166 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 164
def multi_paragraph_quote(opts)
  "“#{opts[:text]}"
end
     | 
  
 
    
      
  
  
    #notextile(opts)  ⇒ Object 
  
  
  
  
    
      
249
250
251
252
253
254
255 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 249
def notextile(opts)
  if filter_html
    html_esc(opts[:text], :html_escape_preformatted)
  else
    opts[:text]
  end
end
     | 
  
 
    
      
  
  
    #quot(opts)  ⇒ Object 
  
  
  
  
    
      
227
228
229 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 227
def quot(opts)
  """
end 
     | 
  
 
    
      
  
  
    #quote1(opts)  ⇒ Object 
  
  
  
  
    
      
156
157
158 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 156
def quote1(opts)
  "‘#{opts[:text]}’"
end
     | 
  
 
    
      
  
  
    #quote2(opts)  ⇒ Object 
  
  
  
  
    
      
160
161
162 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 160
def quote2(opts)
  "“#{opts[:text]}”"
end
     | 
  
 
    
      
  
  
    #registered(opts)  ⇒ Object 
  
  
  
  
    
      
195
196
197 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 195
def registered(opts)
  "®"
end 
     | 
  
 
    
      
  
  
    #snip(opts)  ⇒ Object 
  
  
  
  
    
      
152
153
154 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 152
def snip(opts)
  "<pre#{pba(opts)}><code>#{opts[:text]}</code></pre>\n"
end
     | 
  
 
    
      
  
  
    #squot(opts)  ⇒ Object 
  
  
  
  
    
      
231
232
233 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 231
def squot(opts)
  "’"
end 
     | 
  
 
    
      
  
  
    #table_close(opts)  ⇒ Object 
  
  
  
  
    
      
90
91
92 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 90
def table_close(opts)
  "</table>\n"
end 
     | 
  
 
    
      
  
  
    #table_open(opts)  ⇒ Object 
  
  
  
  
    
      
86
87
88 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 86
def table_open(opts)
  "<table#{pba(opts)}>\n"
end
     | 
  
 
    
      
  
  
    #td(opts)  ⇒ Object 
  
  
  
  
    
      
73
74
75
76 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 73
def td(opts)
  tdtype = opts[:th] ? 'th' : 'td'
  "\t\t<#{tdtype}#{pba(opts)}>#{opts[:text]}</#{tdtype}>\n"
end
     | 
  
 
    
      
  
  
    #tr_close(opts)  ⇒ Object 
  
  
  
  
    
      
82
83
84 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 82
def tr_close(opts)
  "\t</tr>\n"
end 
     | 
  
 
    
      
  
  
    #tr_open(opts)  ⇒ Object 
  
  
  
  
    
      
78
79
80 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 78
def tr_open(opts)
  "\t<tr#{pba(opts)}>\n"
end
     | 
  
 
    
      
  
  
    #trademark(opts)  ⇒ Object 
  
  
  
  
    
      
191
192
193 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 191
def trademark(opts)
  "™"
end 
     | 
  
 
    
      
  
  
    #truncate(text, length = 30, truncate_string = "...")  ⇒ Object 
  
  
  
  
    
      
117
118
119
120
121 
     | 
    
      # File 'lib/redcloth/formatters/html.rb', line 117
def truncate(text, length = 30, truncate_string = "...")
  if text.nil? then return end
  l = length - truncate_string.chars.to_a.size
  (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s
end 
     |