Class: RedCloth::TextileDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/guides/textile_extensions.rb

Instance Method Summary collapse

Instance Method Details

#code(body) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/guides/textile_extensions.rb', line 32

def code(body)
  body.gsub!(%r{<(yaml|shell|ruby|erb|html|sql|plain)>(.*?)</\1>}m) do |m|
    es = ERB::Util.h($2)
    css_class = ['erb', 'shell'].include?($1) ? 'html' : $1
    %{<notextile><div class="code_container"><code class="#{css_class}">#{es}</code></div></notextile>}
  end
end

#notestuff(body) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/guides/textile_extensions.rb', line 2

def notestuff(body)
  body.gsub!(/^(IMPORTANT|CAUTION|WARNING|NOTE|INFO)[.:](.*)$/) do |m|
    css_class = $1.downcase
    css_class = 'warning' if ['caution', 'important'].include?(css_class)

    result = "<div class='#{css_class}'><p>"
    result << $2.strip
    result << '</p></div>'
    result
  end
end

#plusplus(body) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/guides/textile_extensions.rb', line 23

def plusplus(body)
  body.gsub!(/\+(.*?)\+/) do |m|
    "<notextile><tt>#{$1}</tt></notextile>"
  end

  # The real plus sign
  body.gsub!('<plus>', '+')
end

#tip(body) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/guides/textile_extensions.rb', line 14

def tip(body)
  body.gsub!(/^TIP[.:](.*)$/) do |m|
    result = "<div class='info'><p>"
    result << $1.strip
    result << '</p></div>'
    result
  end
end