Class: PBSimply::Processor::PbsRedCarpet

Inherits:
PBSimply
  • Object
show all
Defined in:
lib/pbsimply/docengine/misc.rb

Overview

RedCarpet Processor

Constant Summary

Constants included from ACCS

ACCS::DEFINITIONS, ACCS::INDEX

Constants included from PBSimply::Plugger

PBSimply::Plugger::POST_PROCESSORS

Instance Attribute Summary

Attributes inherited from PBSimply

#indexes

Instance Method Summary collapse

Methods inherited from PBSimply

#delete_missing, #delete_turn_draft, #doc, #generate, load_config, #load_index, #main, #proc_dir, #proc_docs, #target_file_extensions, #treat_cmdline

Methods included from ACCS

#accsmode, #process_accs, #single_accs

Methods included from Frontmatter

#read_frontmatter

Methods included from PBSimply::Plugger

#post_plugins, #pre_plugins

Methods included from PBSimply::Prayer

#autobless, #bless, #bless_cmd, #bless_ruby

Constructor Details

#initialize(config) ⇒ PbsRedCarpet

Returns a new instance of PbsRedCarpet.



7
8
9
10
# File 'lib/pbsimply/docengine/misc.rb', line 7

def initialize(config)
  require 'redcarpet'
  super
end

Instance Method Details



17
18
19
# File 'lib/pbsimply/docengine/misc.rb', line 17

def print_fileproc_msg(filename)
  STDERR.puts "#{filename} generate with Redcarpet Markdown"
end

#process_document(dir, filename, frontmatter, orig_filepath, ext, procdoc) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pbsimply/docengine/misc.rb', line 21

def process_document(dir, filename, frontmatter, orig_filepath, ext, procdoc)
  # Getting HTML string.
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, **@rc_extension)
  article_body = markdown.render(File.read procdoc)

  # Process with eRuby temaplte.
  erb_template = ERB.new(File.read(@config["template"]), trim_mode: '%<>')
  doc = erb_template.result(binding)

  doc
end

#setup_config(dir) ⇒ Object



12
13
14
15
# File 'lib/pbsimply/docengine/misc.rb', line 12

def setup_config(dir)
  super
  @rc_extension = @config["redcarpet_extensions"] || {}
end