Module: RedCloth::Formatters::Plain
- Includes:
- Base
- Defined in:
- lib/red_cloth_formatters_plain.rb
Defined Under Namespace
Classes: Sanitizer
Instance Method Summary collapse
- #acronym(opts) ⇒ Object
- #bc_close(opts) ⇒ Object
- #bq_close(opts) ⇒ Object
- #caps(opts) ⇒ Object
- #dd(opts) ⇒ Object
-
#del(opts) ⇒ Object
don’t render deleted text.
- #dim(opts) ⇒ Object
- #dl_close(opts = nil) ⇒ Object
- #dl_open(opts) ⇒ Object
- #dt(opts) ⇒ Object
- #ellipsis(opts) ⇒ Object
- #entity(opts) ⇒ Object
- #hr(opts) ⇒ Object
-
#html(opts) ⇒ Object
strip HTML tags.
- #html_block(opts) ⇒ Object
-
#ignored_line(opts) ⇒ Object
unchanged.
-
#image(opts) ⇒ Object
render image alternative text or title if not available.
- #inline_html(opts) ⇒ Object
- #li_close(opts = nil) ⇒ Object
- #li_open(opts) ⇒ Object
-
#link(opts) ⇒ Object
render link name followed by <url> uses !LINK_OPEN_TAG! and !LINK_CLOSE_TAG! as a way to identify the < > otherwise they will be stripped when all html tags are stripped.
- #multi_paragraph_quote(opts) ⇒ Object
- #notextile(opts) ⇒ Object
-
#quote1(opts) ⇒ Object
render unescaped quotes and special chars.
- #quote2(opts) ⇒ Object
- #snip(opts) ⇒ Object
Instance Method Details
#acronym(opts) ⇒ Object
44 45 46 47 |
# File 'lib/red_cloth_formatters_plain.rb', line 44 def acronym(opts) opts[:block] = true opts[:title] ? "#{opts[:text]}(#{opts[:title]})" : "#{opts[:text]}" end |
#bc_close(opts) ⇒ Object
107 108 109 |
# File 'lib/red_cloth_formatters_plain.rb', line 107 def bc_close(opts) "\n" end |
#bq_close(opts) ⇒ Object
110 111 112 |
# File 'lib/red_cloth_formatters_plain.rb', line 110 def bq_close(opts) "" end |
#caps(opts) ⇒ Object
49 50 51 |
# File 'lib/red_cloth_formatters_plain.rb', line 49 def caps(opts) "#{opts[:text]}" end |
#dd(opts) ⇒ Object
89 90 91 |
# File 'lib/red_cloth_formatters_plain.rb', line 89 def dd(opts) " #{opts[:text]}\n" end |
#del(opts) ⇒ Object
don’t render deleted text
54 55 56 |
# File 'lib/red_cloth_formatters_plain.rb', line 54 def del(opts) "" end |
#dim(opts) ⇒ Object
170 171 172 |
# File 'lib/red_cloth_formatters_plain.rb', line 170 def dim(opts) opts[:text] end |
#dl_close(opts = nil) ⇒ Object
83 84 85 |
# File 'lib/red_cloth_formatters_plain.rb', line 83 def dl_close(opts=nil) "" end |
#dl_open(opts) ⇒ Object
79 80 81 82 |
# File 'lib/red_cloth_formatters_plain.rb', line 79 def dl_open(opts) opts[:block] = true "" end |
#dt(opts) ⇒ Object
86 87 88 |
# File 'lib/red_cloth_formatters_plain.rb', line 86 def dt(opts) "#{opts[:text]}:\n" end |
#ellipsis(opts) ⇒ Object
148 149 150 |
# File 'lib/red_cloth_formatters_plain.rb', line 148 def ellipsis(opts) "#{opts[:text]}..." end |
#entity(opts) ⇒ Object
173 174 175 |
# File 'lib/red_cloth_formatters_plain.rb', line 173 def entity(opts) unescape("&#{opts[:text]};") end |
#hr(opts) ⇒ Object
40 41 42 |
# File 'lib/red_cloth_formatters_plain.rb', line 40 def hr(opts) "\n" end |
#html(opts) ⇒ Object
strip HTML tags
178 179 180 |
# File 'lib/red_cloth_formatters_plain.rb', line 178 def html(opts) (opts[:text]) + "\n" end |
#html_block(opts) ⇒ Object
181 182 183 |
# File 'lib/red_cloth_formatters_plain.rb', line 181 def html_block(opts) (opts[:text]) end |
#ignored_line(opts) ⇒ Object
unchanged
200 201 202 |
# File 'lib/red_cloth_formatters_plain.rb', line 200 def ignored_line(opts) opts[:text] + "\n" end |
#image(opts) ⇒ Object
render image alternative text or title if not available
123 124 125 |
# File 'lib/red_cloth_formatters_plain.rb', line 123 def image(opts) "#{opts[:alt] || opts[:title]}" end |
#inline_html(opts) ⇒ Object
191 192 193 194 195 196 197 |
# File 'lib/red_cloth_formatters_plain.rb', line 191 def inline_html(opts) if filter_html "#{opts[:text]}" else (opts[:text]) end end |
#li_close(opts = nil) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/red_cloth_formatters_plain.rb', line 73 def li_close(opts=nil) # avoid multiple line breaks when closing multiple list items output = @li_need_closing ? "\n" : "" @li_need_closing = false output end |
#li_open(opts) ⇒ Object
68 69 70 71 72 |
# File 'lib/red_cloth_formatters_plain.rb', line 68 def li_open(opts) @li_need_closing = true num = opts[:nest] - 1 "#{" " * (num > 0 ? num : 0)}- #{opts[:text]}" end |
#link(opts) ⇒ Object
render link name followed by <url> uses !LINK_OPEN_TAG! and !LINK_CLOSE_TAG! as a way to identify the < > otherwise they will be stripped when all html tags are stripped
118 119 120 |
# File 'lib/red_cloth_formatters_plain.rb', line 118 def link(opts) "#{opts[:name]} !LINK_OPEN_TAG!#{opts[:href]}!LINK_CLOSE_TAG!" end |
#multi_paragraph_quote(opts) ⇒ Object
145 146 147 |
# File 'lib/red_cloth_formatters_plain.rb', line 145 def multi_paragraph_quote(opts) "\"#{opts[:text]}" end |
#notextile(opts) ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/red_cloth_formatters_plain.rb', line 184 def notextile(opts) if filter_html "#{opts[:text]}" else (opts[:text]) end end |
#quote1(opts) ⇒ Object
render unescaped quotes and special chars
139 140 141 |
# File 'lib/red_cloth_formatters_plain.rb', line 139 def quote1(opts) "'#{opts[:text]}'" end |
#quote2(opts) ⇒ Object
142 143 144 |
# File 'lib/red_cloth_formatters_plain.rb', line 142 def quote2(opts) "\"#{opts[:text]}\"" end |
#snip(opts) ⇒ Object
134 135 136 |
# File 'lib/red_cloth_formatters_plain.rb', line 134 def snip(opts) opts[:text] + "\n" end |