Sha256: 628829006c274a307da9a056cbac97f8954612f1da588b39532239125da55e16

Contents?: true

Size: 1.01 KB

Versions: 14

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true
require_relative 'template'
require 'pandoc-ruby'

# Pandoc markdown implementation. See: http://pandoc.org/
Tilt::PandocTemplate = Tilt::StaticTemplate.subclass do
  # turn options hash into an array
  # Map tilt options to pandoc options
  # Replace hash keys with value true with symbol for key
  # Remove hash keys with value false
  # Leave other hash keys untouched
  pandoc_options = []
  from = "markdown"
  smart_extension = "-smart"
  @options.each do |k,v|
    case k
    when :smartypants
      smart_extension = "+smart" if v
    when :escape_html
      from = "markdown-raw_html" if v
    when :commonmark
      from = "commonmark" if v
    when :markdown_strict
      from = "markdown_strict" if v
    else
      case v
      when true
        pandoc_options << k
      when false
        # do nothing
      else
        pandoc_options << { k => v }
      end
    end
  end
  pandoc_options << { :f => from + smart_extension }

  PandocRuby.new(@data, *pandoc_options).to_html.strip
end

Version data entries

14 entries across 13 versions & 5 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
tilt-2.6.0 lib/tilt/pandoc.rb
brakeman-7.0.0 bundle/ruby/3.1.0/gems/tilt-2.5.0/lib/tilt/pandoc.rb
tilt-2.5.0 lib/tilt/pandoc.rb
brakeman-6.2.2 bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
brakeman-6.2.2.rc1 bundle/ruby/3.3.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
brakeman-6.2.1 bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
brakeman-6.2.0 bundle/ruby/3.1.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/tilt-2.4.0/lib/tilt/pandoc.rb
tilt-2.4.0 lib/tilt/pandoc.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/tilt-2.3.0/lib/tilt/pandoc.rb
tilt-2.3.0 lib/tilt/pandoc.rb
tilt-2.2.0 lib/tilt/pandoc.rb