Class: Mato::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_factoryClass<Mato::Document>

Returns:



41
42
43
# File 'lib/mato/config.rb', line 41

def document_factory
  @document_factory
end

#html_filtersArray<Proc>

Returns:

  • (Array<Proc>)


32
33
34
# File 'lib/mato/config.rb', line 32

def html_filters
  @html_filters
end

#html_parserCass<Nokogiri::HTML4::DocumentFragment>

Returns:

  • (Cass<Nokogiri::HTML4::DocumentFragment>)


38
39
40
# File 'lib/mato/config.rb', line 38

def html_parser
  @html_parser
end

#markdown_filtersArray<Proc>

Returns:

  • (Array<Proc>)


29
30
31
# File 'lib/mato/config.rb', line 29

def markdown_filters
  @markdown_filters
end

#markdown_optionsHash

Returns Commonmarker’s options.

Returns:

  • (Hash)

    Commonmarker’s options



44
45
46
# File 'lib/mato/config.rb', line 44

def markdown_options
  @markdown_options
end

#markdown_parserClass<Commonmarker]

Returns Class<Commonmarker].

Returns:

  • (Class<Commonmarker])

    Class<Commonmarker]



35
36
37
# File 'lib/mato/config.rb', line 35

def markdown_parser
  @markdown_parser
end

#text_filtersArray<Proc>

Returns:

  • (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

Parameters:

  • block (Proc)

Yield Parameters:



61
62
63
# File 'lib/mato/config.rb', line 61

def configure(&block)
  block.call(self)
end