Class: Showoff::Compiler
- Inherits:
-
Object
- Object
- Showoff::Compiler
- Defined in:
- lib/showoff/compiler.rb
Defined Under Namespace
Classes: Downloads, Fixups, Form, Glossary, I18n, Notes, TableOfContents, Variables
Instance Method Summary collapse
-
#initialize(options) ⇒ Compiler
constructor
A new instance of Compiler.
-
#profile ⇒ Object
Configures Tilt with the selected engine and options.
-
#render(content) ⇒ [String, Array<String>]
Compiles markdown and all Showoff extensions into the final HTML output and notes.
Constructor Details
#initialize(options) ⇒ Compiler
Returns a new instance of Compiler.
15 16 17 18 |
# File 'lib/showoff/compiler.rb', line 15 def initialize() @options = @profile = profile end |
Instance Method Details
#profile ⇒ Object
Configures Tilt with the selected engine and options.
Returns render options profile hash
Source:
https://github.com/puppetlabs/showoff/blob/3f43754c84f97be4284bb34f9bc7c42175d45226/lib/showoff_utils.rb#L671-L720
TODO: per slide profiles of render options
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/showoff/compiler.rb', line 27 def profile renderer = Showoff::Config.get('markdown') profile = Showoff::Config.get(renderer) begin # Load markdown configuration case renderer when 'rdiscount' Tilt.prefer Tilt::RDiscountTemplate, "markdown" when 'maruku' Tilt.prefer Tilt::MarukuTemplate, "markdown" # Now check if we can go for latex mode require 'maruku' require 'maruku/ext/math' if profile[:use_tex] MaRuKu::Globals[:html_math_output_mathml] = false MaRuKu::Globals[:html_math_output_png] = true MaRuKu::Globals[:html_math_engine] = 'none' MaRuKu::Globals[:html_png_engine] = 'blahtex' MaRuKu::Globals[:html_png_dir] = profile[:png_dir] MaRuKu::Globals[:html_png_url] = profile[:html_png_url] end when 'bluecloth' Tilt.prefer Tilt::BlueClothTemplate, "markdown" when 'kramdown' Tilt.prefer Tilt::KramdownTemplate, "markdown" when 'commonmarker', 'commonmark' Tilt.prefer Tilt::CommonMarkerTemplate, "markdown" when 'redcarpet', :default Tilt.prefer Tilt::RedcarpetTemplate, "markdown" else raise 'Unsupported markdown renderer' end rescue LoadError puts "ERROR: The #{renderer} markdown rendering engine does not appear to be installed correctly." exit 1 end profile end |
#render(content) ⇒ [String, Array<String>]
TODO:
I think the update_image_paths() malarky is redundant. Verify that.
Compiles markdown and all Showoff extensions into the final HTML output and notes.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/showoff/compiler.rb', line 82 def render(content) Variables::interpolate!(content) I18n.selectLanguage!(content) html = Tilt[:markdown].new(nil, nil, @profile) { content }.render doc = Nokogiri::HTML::DocumentFragment.parse(html) Form.render!(doc, @options) Fixups.updateClasses!(doc) Fixups.updateLinks!(doc) Fixups.updateSyntaxHighlighting!(doc) Fixups.updateCommandlineBlocks!(doc) Fixups.updateImagePaths!(doc, @options) Glossary.render!(doc) Downloads.scanForFiles!(doc, @options) # This call must be last in the chain because it separates notes from the # content and returns them separately. If it's not last, then the notes # won't have all the compilation steps applied to them. # # must pass in extra context because this will render markdown itself Notes.render!(doc, @profile, @options) end |