Class: Mato::Config
- Inherits:
-
Object
- Object
- Mato::Config
- Defined in:
- lib/mato/config.rb
Constant Summary collapse
- DEFAULT_MARKDOWN_PARSE_OPTIONS =
%i[ DEFAULT VALIDATE_UTF8 FOOTNOTES ].freeze
- DEFAULT_MARKDOWN_RENDER_OPTIONS =
[ :DEFAULT, :HARDBREAKS, # convert "\n" as <br/> :TABLE_PREFER_STYLE_ATTRIBUTES, :UNSAFE, # :SOURCEPOS, // TODO: enable it after assertions are supported ].freeze
- DEFAULT_MARKDOWN_EXTENSIONS =
%i[ table strikethrough autolink tagfilter ].freeze
Instance Attribute Summary collapse
- #document_factory ⇒ Class<Mato::Document>
- #html_filters ⇒ Array<Proc>
- #html_parser ⇒ Cass<Nokogiri::HTML::DocumentFragment>
-
#markdown_extensions ⇒ Array<Symbol>
CommonMarker’s parse extensions.
- #markdown_filters ⇒ Array<Proc>
-
#markdown_parse_options ⇒ Array<Symbol>
CommonMarker’s pars options.
-
#markdown_parser ⇒ Class<CommonMarker]
Class<CommonMarker].
-
#markdown_render_options ⇒ Array<Symbol>
CommonMarker’s HTML rendering options.
- #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.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/mato/config.rb', line 60 def initialize @text_filters = [] @markdown_filters = [] @html_filters = [] @markdown_parser = CommonMarker @html_parser = Nokogiri::HTML::DocumentFragment @document_factory = Document @markdown_extensions = DEFAULT_MARKDOWN_EXTENSIONS @markdown_parse_options = DEFAULT_MARKDOWN_PARSE_OPTIONS @markdown_render_options = DEFAULT_MARKDOWN_RENDER_OPTIONS end |
Instance Attribute Details
#document_factory ⇒ Class<Mato::Document>
49 50 51 |
# File 'lib/mato/config.rb', line 49 def document_factory @document_factory end |
#html_filters ⇒ Array<Proc>
40 41 42 |
# File 'lib/mato/config.rb', line 40 def html_filters @html_filters end |
#html_parser ⇒ Cass<Nokogiri::HTML::DocumentFragment>
46 47 48 |
# File 'lib/mato/config.rb', line 46 def html_parser @html_parser end |
#markdown_extensions ⇒ Array<Symbol>
Returns CommonMarker’s parse extensions.
52 53 54 |
# File 'lib/mato/config.rb', line 52 def markdown_extensions @markdown_extensions end |
#markdown_filters ⇒ Array<Proc>
37 38 39 |
# File 'lib/mato/config.rb', line 37 def markdown_filters @markdown_filters end |
#markdown_parse_options ⇒ Array<Symbol>
Returns CommonMarker’s pars options.
55 56 57 |
# File 'lib/mato/config.rb', line 55 def @markdown_parse_options end |
#markdown_parser ⇒ Class<CommonMarker]
Returns Class<CommonMarker].
43 44 45 |
# File 'lib/mato/config.rb', line 43 def markdown_parser @markdown_parser end |
#markdown_render_options ⇒ Array<Symbol>
Returns CommonMarker’s HTML rendering options.
58 59 60 |
# File 'lib/mato/config.rb', line 58 def @markdown_render_options end |
#text_filters ⇒ Array<Proc>
34 35 36 |
# File 'lib/mato/config.rb', line 34 def text_filters @text_filters end |
Instance Method Details
#append_html_filter(html_filter, timeout: nil, on_timeout: nil, on_error: nil) ⇒ Object
93 94 95 96 97 |
# File 'lib/mato/config.rb', line 93 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
87 88 89 90 91 |
# File 'lib/mato/config.rb', line 87 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
81 82 83 84 85 |
# File 'lib/mato/config.rb', line 81 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
77 78 79 |
# File 'lib/mato/config.rb', line 77 def configure(&block) block.call(self) end |