class Redcarpet::Render::Hiki

Public Class Methods

new(render_extensions) click to toggle source
Calls superclass method
# File lib/redcarpet/render/hiki.rb, line 5
def initialize(render_extensions)
  super()
  @header_offset = 0
  if render_extensions[:header_offset]
    @header_offset = render_extensions[:header_offset]
  end
end

Public Instance Methods

block_code(code, language) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 22
def block_code(code, language)
  code_text = normal_text(code).chomp
  code_text.gsub!(/^/,'  ')
  "\n#{code_text}\n\n"
end
block_html(raw_html) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 34
def block_html(raw_html)
  html_text = raw_html.chomp
  warning = "XXX: BLOCK_HTML: YOU SHOULD REWRITE IT"
  "\n#{warning}\n#{html_text}\n\n"
end
block_quote(quote) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 28
def block_quote(quote)
  quote_text = normal_text(quote).chomp
  quote_text.gsub!(/^/,'""')
  "\n#{quote_text}\n\n"
end
codespan(code) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 44
def codespan(code)
  "``#{escape_inline(code)}``"
end
double_emphasis(text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 95
def double_emphasis(text)
  "''#{escape_inline(text)}''"
end
emphasis(text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 99
def emphasis(text)
  "'#{escape_inline(text)}'"
end
escape_inline(text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 17
def escape_inline(text)
  ## text.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
  text
end
header(title, level) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 48
def header(title, level)
  l = level - @header_offset
  case l
  when 1
    "\n! #{title}\n"
  when 2
    "\n!! #{title}\n"
  when 3
    "\n!!!! #{title}\n"
  when 4
    "\n!!!! #{title}\n"
  when 5
    "\n!!!!! #{title}\n"
  end
end
hrule() click to toggle source
# File lib/redcarpet/render/hiki.rb, line 40
def hrule
  "\n//hr\n"
end
image(link, title, alt_text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 81
def image(link, title, alt_text)
  filename = File.basename(link,".*")
  text = alt_text || title
  "[[#{text}|#{link}]]"
end
linebreak() click to toggle source
# File lib/redcarpet/render/hiki.rb, line 107
def linebreak
  "\n\n"
end
list(content, list_type) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 115
def list(content, list_type)
  case list_type
  when :ordered
    "\n"
  when :unordered
    "\n"
  end
end
list_item(content, list_type) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 124
def list_item(content, list_type)
  case list_type
  when :ordered
    "# #{content.strip}\n"
  when :unordered
    "* #{content.strip}\n"
  end
end
normal_text(text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 13
def normal_text(text)
  text
end
paragraph(text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 111
def paragraph(text)
  "\n\n#{text}\n"
end
strikethrough(text) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 103
def strikethrough(text)
  "==#{escape_inline(text)}=="
end
table(header, body) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 64
def table(header, body)
  header_text = ""
  if header
    header_text = header
  end
  body.chomp!
  "#{header_text}\n\n#{body}\n"
end
table_cell(content, alignment) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 77
def table_cell(content, alignment)
  "||#{content}"
end
table_row(content) click to toggle source
# File lib/redcarpet/render/hiki.rb, line 73
def table_row(content)
  content+"\n"
end