Sha256: f919a581f0ebb168bb89d2658031f01347ac853ae86465cf5a1f00f4528455f3
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
require 'kramdown' module Cheepub class Markdown RUBY_PATTERN = /{([^}]+)\|([^}]+)}/ TCY_PATTERN = /\^([\u0020-\u005d\u005f\u007e]+)\^/ ## \u005e is "^" def self.parse(filename, **params) Markdown.new(File.read(filename), params) end def initialize(text, **params) default_params = {template: File.join(File.dirname(__FILE__), "templates/bodymatter.html.erb"), lang: "ja", title: "content", cssfile: "style.css", generator: "Cheepub #{Cheepub::VERSION} with kramdown #{Kramdown::VERSION}", input: "cheemarkdown", } @params = default_params.merge(params) @text = text end def convert params = @params.dup params[:syntax_highlighter] = "coderay" Kramdown::Document.new(@text, params).to_html end def to_latex params = @params.dup params[:template] = File.join(File.dirname(__FILE__), "templates/bodymatter.tex.erb") params[:latex_headers] = %w{chapter* section* subsection* subsubsection* paragraph* subparagraph*} Kramdown::Document.new(@text, params).to_latex end alias_method :to_html, :convert def save_as(filename) html = convert File.write(filename, html) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cheepub-0.7.0 | lib/cheepub/markdown.rb |
cheepub-0.6.1 | lib/cheepub/markdown.rb |