Class: HTML::Pipeline::LFMarkdown

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/html/pipeline/markdown_filter.rb

Overview

LinuxFr Flavored Markdown

Constant Summary collapse

PARSER_OPTIONS =
{
  :no_intra_emphasis  => true,
  :tables             => true,
  :fenced_code_blocks => true,
  :autolink           => true,
  :strikethrough      => true,
  :superscript        => true,
  :footnotes          => true,
}
HTML_OPTIONS =
{
  :filter_html        => true,
  :no_styles          => true,
  :hard_wrap          => true,
  :xhtml              => true,
}

Instance Method Summary collapse

Constructor Details

#initialize(extensions = {}) ⇒ LFMarkdown

Returns a new instance of LFMarkdown.



27
28
29
# File 'lib/html/pipeline/markdown_filter.rb', line 27

def initialize(extensions={})
  super extensions.merge(HTML_OPTIONS)
end

Instance Method Details

#header(text, header_level, anchor = nil) ⇒ Object



31
32
33
34
# File 'lib/html/pipeline/markdown_filter.rb', line 31

def header(text, header_level, anchor=nil)
  l = header_level + 1
  "<h#{l}>#{text}</h#{l}>\n"
end

#image(link, title, alt_text) ⇒ Object



40
41
42
43
# File 'lib/html/pipeline/markdown_filter.rb', line 40

def image(link, title, alt_text)
  return "" if link.blank?
  ::Image.new(link, title, alt_text).to_html  # FIXME
end

#normal_text(text) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/html/pipeline/markdown_filter.rb', line 45

def normal_text(text)
  text = CGI.escapeHTML(text)
  text.gsub!('« ', '«&nbsp;')
  text.gsub!(/ ([:;»!?])/, '&nbsp;\1')
  text.gsub!(' -- ', '')
  text.gsub!('...', '')
  text
end

#strikethrough(text) ⇒ Object



36
37
38
# File 'lib/html/pipeline/markdown_filter.rb', line 36

def strikethrough(text)
  "<s>#{text}</s>"
end