Module: MarkdownConfig

Defined in:
lib/showoff_utils.rb

Overview

Load the configuration for the markdown engine from the showoff.json file

Class Method Summary collapse

Class Method Details

.defaults(dir_name) ⇒ Object



720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# File 'lib/showoff_utils.rb', line 720

def self.defaults(dir_name)
  case ShowOffUtils.showoff_markdown(dir_name)
  when 'rdiscount'
    {
      :autolink          => true,
    }
  when 'maruku'
    {}
  when 'bluecloth'
    {
      :auto_links        => true,
      :definition_lists  => true,
      :superscript       => true,
      :tables            => true,
    }
  when 'kramdown'
    {}
  else
    {
      :autolink          => true,
      :no_intra_emphasis => true,
      :superscript       => true,
      :tables            => true,
      :underline         => true,
    }
  end
end

.setup(dir_name) ⇒ Object



669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# File 'lib/showoff_utils.rb', line 669

def self.setup(dir_name)
  require 'tilt'
  require 'tilt/erb'

  renderer = ShowOffUtils.showoff_markdown(dir_name)
  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'

      # Load maruku options
      opts = ShowOffUtils.showoff_renderer_options(dir_name,
                                                   { :use_tex      => false,
                                                     :png_dir      => 'images',
                                                     :html_png_url => '/file/images/'})

      if opts[: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]    = opts[:png_dir]
        MaRuKu::Globals[:html_png_url]    = opts[: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"

    else
      Tilt.prefer Tilt::RedcarpetTemplate, "markdown"

    end
  rescue LoadError
    puts "ERROR: The #{renderer} markdown rendering engine does not appear to be installed correctly."
    exit! 1
  end
end