Class: Mato::Config
- Inherits:
-
Object
- Object
- Mato::Config
- Defined in:
- lib/mato/config.rb
Constant Summary collapse
- DEFAULT_MARKDOWN_OPTIONS =
{ render: { hardbreaks: true, unsafe: true, }, extension: { table: true, strikethrough: true, autolink: true, tagfilter: true, tasklist: false, shortcodes: false, footnotes: true, }, }.freeze
Instance Attribute Summary collapse
- #document_factory ⇒ Class<Mato::Document>
- #html_filters ⇒ Array<Proc>
- #html_parser ⇒ Cass<Nokogiri::HTML4::DocumentFragment>
- #markdown_filters ⇒ Array<Proc>
-
#markdown_options ⇒ Hash
Commonmarker’s options.
-
#markdown_parser ⇒ Class<Commonmarker]
Class<Commonmarker].
- #text_filters ⇒ Array<Proc>
Instance Method Summary collapse
- #append_html_filter(html_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
- #append_markdown_filter(markdown_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
- #append_text_filter(text_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
- #configure(&block) {|config| ... } ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mato/config.rb', line 46 def initialize @text_filters = [] @markdown_filters = [] @html_filters = [] @markdown_parser = Commonmarker @html_parser = Nokogiri::HTML4::DocumentFragment @document_factory = Document @markdown_options = DEFAULT_MARKDOWN_OPTIONS end |
Instance Attribute Details
#document_factory ⇒ Class<Mato::Document>
41 42 43 |
# File 'lib/mato/config.rb', line 41 def document_factory @document_factory end |
#html_filters ⇒ Array<Proc>
32 33 34 |
# File 'lib/mato/config.rb', line 32 def html_filters @html_filters end |
#html_parser ⇒ Cass<Nokogiri::HTML4::DocumentFragment>
38 39 40 |
# File 'lib/mato/config.rb', line 38 def html_parser @html_parser end |
#markdown_filters ⇒ Array<Proc>
29 30 31 |
# File 'lib/mato/config.rb', line 29 def markdown_filters @markdown_filters end |
#markdown_options ⇒ Hash
Returns Commonmarker’s options.
44 45 46 |
# File 'lib/mato/config.rb', line 44 def @markdown_options end |
#markdown_parser ⇒ Class<Commonmarker]
Returns Class<Commonmarker].
35 36 37 |
# File 'lib/mato/config.rb', line 35 def markdown_parser @markdown_parser end |
#text_filters ⇒ Array<Proc>
26 27 28 |
# File 'lib/mato/config.rb', line 26 def text_filters @text_filters end |
Instance Method Details
#append_html_filter(html_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
77 78 79 80 81 |
# File 'lib/mato/config.rb', line 77 def append_html_filter(html_filter, timeout: nil, on_timeout: nil, on_error: nil) raise "html_filter must respond to call()" unless html_filter.respond_to?(:call) html_filters.push(wrap(html_filter, timeout: timeout, on_timeout: on_timeout, on_error: on_error)) end |
#append_markdown_filter(markdown_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
71 72 73 74 75 |
# File 'lib/mato/config.rb', line 71 def append_markdown_filter(markdown_filter, timeout: nil, on_timeout: nil, on_error: nil) raise "markdown_filter must respond to call()" unless markdown_filter.respond_to?(:call) markdown_filters.push(wrap(markdown_filter, timeout: timeout, on_timeout: on_timeout, on_error: on_error)) end |
#append_text_filter(text_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
65 66 67 68 69 |
# File 'lib/mato/config.rb', line 65 def append_text_filter(text_filter, timeout: nil, on_timeout: nil, on_error: nil) raise "text_filter must respond to call()" unless text_filter.respond_to?(:call) text_filters.push(wrap(text_filter, timeout: timeout, on_timeout: on_timeout, on_error: on_error)) end |
#configure(&block) {|config| ... } ⇒ Object
61 62 63 |
# File 'lib/mato/config.rb', line 61 def configure(&block) block.call(self) end |