Class: Tilt::CommonMarkerTemplate
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, :SOURCEPOS,
:TABLE_PREFER_STYLE_ATTRIBUTES,
:UNSAFE,
].freeze
- EXTENSIONS =
[
:autolink,
:strikethrough,
:table,
:tagfilter,
:tasklist,
].freeze
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #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
84
85
86
|
# File 'lib/tilt/commonmarker.rb', line 84
def allows_script?
false
end
|
#evaluate(scope, locals, &block) ⇒ Object
79
80
81
82
|
# File '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
|
#extensions ⇒ Object
39
40
41
42
43
|
# File 'lib/tilt/commonmarker.rb', line 39
def extensions
EXTENSIONS.select do |extension|
options[extension]
end
end
|
#parse_options ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File '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
|
#prepare ⇒ Object
74
75
76
77
|
# File 'lib/tilt/commonmarker.rb', line 74
def prepare
@engine = nil
@output = nil
end
|
#render_options ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File '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
|