module RedCloth::Formatters::HTML
Constants
- BASIC_TAGS
HTML
cleansing stuff
Public Instance Methods
acronym(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 21 def acronym(opts) 22 opts[:block] = true 23 "<acronym#{pba(opts)}>#{caps(:text => opts[:text])}</acronym>" 24 end
amp(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 200 def amp(opts) 201 "&" 202 end
apos(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 228 def apos(opts) 229 "'" 230 end
arrow(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 173 def arrow(opts) 174 "→" 175 end
bc_close(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 99 def bc_close(opts) 100 "</pre>\n" 101 end
bc_open(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 94 def bc_open(opts) 95 opts[:block] = true 96 "<pre#{pba(opts)}>" 97 end
bq_close(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 109 def bq_close(opts) 110 "</blockquote>\n" 111 end
bq_open(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 103 def bq_open(opts) 104 opts[:block] = true 105 cite = opts[:cite] ? " cite=\"#{ escape_attribute opts[:cite] }\"" : '' 106 "<blockquote#{cite}#{pba(opts)}>\n" 107 end
br(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 212 def br(opts) 213 if hard_breaks == false 214 "\n" 215 else 216 "<br#{pba(opts)} />\n" 217 end 218 end
caps(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 26 def caps(opts) 27 if no_span_caps 28 opts[:text] 29 else 30 opts[:class] = 'caps' 31 span(opts) 32 end 33 end
copyright(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 192 def copyright(opts) 193 "©" 194 end
del(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 35 def del(opts) 36 opts[:block] = true 37 "<del#{pba(opts)}>#{opts[:text]}</del>" 38 end
dim(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 177 def dim(opts) 178 opts[:text].gsub!('x', '×') 179 opts[:text].gsub!("'", '′') 180 opts[:text].gsub!('"', '″') 181 opts[:text] 182 end
dl_close(opts=nil)
click to toggle source
# File lib/redcloth/formatters/html.rb 63 def dl_close(opts=nil) 64 "</dl>\n" 65 end
dl_open(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 58 def dl_open(opts) 59 opts[:block] = true 60 "<dl#{pba(opts)}>\n" 61 end
ellipsis(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 161 def ellipsis(opts) 162 "#{opts[:text]}…" 163 end
emdash(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 165 def emdash(opts) 166 "—" 167 end
endash(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 169 def endash(opts) 170 " – " 171 end
entity(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 196 def entity(opts) 197 "&#{opts[:text]};" 198 end
fn(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 138 def fn(opts) 139 no = opts[:id] 140 opts[:id] = "fn#{no}" 141 opts[:class] = ["footnote", opts[:class]].compact.join(" ") 142 "<p#{pba(opts)}><a href=\"#fnr#{no}\"><sup>#{no}</sup></a> #{opts[:text]}</p>\n" 143 end
footno(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 133 def footno(opts) 134 opts[:id] ||= opts[:text] 135 %Q{<sup class="footnote" id=\"fnr#{opts[:id]}\"><a href=\"#fn#{opts[:id]}\">#{opts[:text]}</a></sup>} 136 end
gt(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 204 def gt(opts) 205 ">" 206 end
hr(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 17 def hr(opts) 18 "<hr#{pba(opts)} />\n" 19 end
html(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 232 def html(opts) 233 "#{opts[:text]}\n" 234 end
html_block(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 236 def html_block(opts) 237 inline_html(:text => "#{opts[:indent_before_start]}#{opts[:start_tag]}#{opts[:indent_after_start]}") + 238 "#{opts[:text]}" + 239 inline_html(:text => "#{opts[:indent_before_end]}#{opts[:end_tag]}#{opts[:indent_after_end]}") 240 end
ignored_line(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 258 def ignored_line(opts) 259 opts[:text] + "\n" 260 end
image(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 121 def image(opts) 122 if (filter_html || sanitize_html) && ( opts[:src] =~ /^\s*javascript:/i || opts[:href] =~ /^\s*javascript:/i ) 123 opts[:title] 124 else 125 opts.delete(:align) 126 opts[:alt] = opts[:title] 127 img = "<img src=\"#{escape_attribute opts[:src]}\"#{pba(opts)} alt=\"#{escape_attribute opts[:alt].to_s}\" />" 128 img = "<a href=\"#{escape_attribute opts[:href]}\">#{img}</a>" if opts[:href] 129 img 130 end 131 end
inline_html(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 250 def inline_html(opts) 251 if filter_html 252 html_esc(opts[:text], :html_escape_preformatted) 253 else 254 "#{opts[:text]}" # nil-safe 255 end 256 end
li_close(opts=nil)
click to toggle source
# File lib/redcloth/formatters/html.rb 54 def li_close(opts=nil) 55 "</li>\n" 56 end
li_open(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 50 def li_open(opts) 51 "#{"\t" * opts[:nest]}<li#{pba(opts)}>#{opts[:text]}" 52 end
link(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 113 def link(opts) 114 if (filter_html || sanitize_html) && opts[:href] =~ /^\s*javascript:/i 115 opts[:name] 116 else 117 "<a href=\"#{escape_attribute opts[:href]}\"#{pba(opts)}>#{opts[:name]}</a>" 118 end 119 end
lt(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 208 def lt(opts) 209 "<" 210 end
multi_paragraph_quote(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 157 def multi_paragraph_quote(opts) 158 "“#{opts[:text]}" 159 end
notextile(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 242 def notextile(opts) 243 if filter_html 244 html_esc(opts[:text], :html_escape_preformatted) 245 else 246 opts[:text] 247 end 248 end
quot(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 220 def quot(opts) 221 """ 222 end
quote1(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 149 def quote1(opts) 150 "‘#{opts[:text]}’" 151 end
quote2(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 153 def quote2(opts) 154 "“#{opts[:text]}”" 155 end
registered(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 188 def registered(opts) 189 "®" 190 end
snip(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 145 def snip(opts) 146 "<pre#{pba(opts)}><code>#{opts[:text]}</code></pre>\n" 147 end
squot(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 224 def squot(opts) 225 "’" 226 end
table_close(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 90 def table_close(opts) 91 "</table>\n" 92 end
table_open(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 86 def table_open(opts) 87 "<table#{pba(opts)}>\n" 88 end
td(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 73 def td(opts) 74 tdtype = opts[:th] ? 'th' : 'td' 75 "\t\t<#{tdtype}#{pba(opts)}>#{opts[:text]}</#{tdtype}>\n" 76 end
tr_close(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 82 def tr_close(opts) 83 "\t</tr>\n" 84 end
tr_open(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 78 def tr_open(opts) 79 "\t<tr#{pba(opts)}>\n" 80 end
trademark(opts)
click to toggle source
# File lib/redcloth/formatters/html.rb 184 def trademark(opts) 185 "™" 186 end