Class: Tilt::CommonMarkerTemplate

Inherits:
Template show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb

Constant Summary collapse

OPTION_ALIAS =
{
  :smartypants => :SMART
}
PARSE_OPTIONS =
[
  :FOOTNOTES,
  :LIBERAL_HTML_TAG,
  :SMART,
  :smartypants,
  :STRIKETHROUGH_DOUBLE_TILDE,
  :UNSAFE,
  :VALIDATE_UTF8,
].freeze
RENDER_OPTIONS =
[
  :FOOTNOTES,
  :FULL_INFO_STRING,
  :GITHUB_PRE_LANG,
  :HARDBREAKS,
  :NOBREAKS,
  :SAFE, # Removed in v0.18.0 (2018-10-17)
  :SOURCEPOS,
  :TABLE_PREFER_STYLE_ATTRIBUTES,
  :UNSAFE,
].freeze
EXTENSIONS =
[
  :autolink,
  :strikethrough,
  :table,
  :tagfilter,
  :tasklist,
].freeze

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

Methods inherited from Template

#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#allows_script?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb', line 84

def allows_script?
  false
end

#evaluate(scope, locals, &block) ⇒ Object



79
80
81
82
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb', line 79

def evaluate(scope, locals, &block)
  doc = CommonMarker.render_doc(data, parse_options, extensions)
  doc.to_html(render_options, extensions)
end

#extensionsObject



39
40
41
42
43
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb', line 39

def extensions
  EXTENSIONS.select do |extension|
    options[extension]
  end
end

#parse_optionsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb', line 45

def parse_options
  raw_options = PARSE_OPTIONS.select do |option|
    options[option]
  end
  actual_options = raw_options.map do |option|
    OPTION_ALIAS[option] || option
  end

  if actual_options.any?
    actual_options
  else
    :DEFAULT
  end
end

#prepareObject



74
75
76
77
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb', line 74

def prepare
  @engine = nil
  @output = nil
end

#render_optionsObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/commonmarker.rb', line 60

def render_options
  raw_options = RENDER_OPTIONS.select do |option|
    options[option]
  end
  actual_options = raw_options.map do |option|
    OPTION_ALIAS[option] || option
  end
  if actual_options.any?
    actual_options
  else
    :DEFAULT
  end
end