class NishisukeBlogSyntax::RawText

Attributes

text[R]

Public Class Methods

new(text) click to toggle source
# File lib/nishisuke_blog_syntax/raw_text.rb, line 10
def initialize(text)
  @text = text.gsub(/\R/, "\n")
end

Private Class Methods

html_formatters() click to toggle source
# File lib/nishisuke_blog_syntax/raw_text.rb, line 22
def self.html_formatters
  # order is important!
  # Each formatter should be commutative.
  # But be careful order for the future.
  @@formatters ||= [
    Formatter::ShellFormatter.new,
    Formatter::CodeFormatter.new,
    Formatter::ParagraphFormatter.new,
    Formatter::SubHeadlineFormatter.new,
    Formatter::HeadThreeFormatter.new,
    Formatter::ListFormatter.new,
  ]
end

Public Instance Methods

to_html() click to toggle source
# File lib/nishisuke_blog_syntax/raw_text.rb, line 14
def to_html
  self.class.html_formatters.inject(text) do |html, f|
    f.format(html)
  end
end