class Mdx::MdxRender
Attributes
title[R]
Public Class Methods
load_templates()
click to toggle source
# File lib/mdx.rb, line 26 def self.load_templates @@templates = {} begin io = File.read(__FILE__).force_encoding(Encoding::UTF_8) app, data = io.gsub("\r\n", "\n").split(/^__END__$/, 2) rescue Errno::ENOENT app, data = nil end if data template = nil data.each_line do |line| if line =~ /^@@\s*(.*\S)\s*$/ template = '' @@templates[$1.to_sym] = template elsif template template << line end end end @@default_style = Sass::Engine.new(@@templates[:style], syntax: :scss, style: :compressed).to_css end
new()
click to toggle source
Calls superclass method
# File lib/mdx.rb, line 13 def initialize @level = 8 super end
Public Instance Methods
header(title, level)
click to toggle source
# File lib/mdx.rb, line 18 def header title, level if level < @level || !@title @title = title @level = level end "<h#{level}>#{title}</h#{level}>" end
postprocess(doc)
click to toggle source
# File lib/mdx.rb, line 51 def postprocess doc style = @style || @@default_style @@templates[:html] % [@title, style, doc] end