Class: Gollum::Filter

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/gollum-lib/filter.rb

Defined Under Namespace

Classes: BibTeX, Code, CriticMarkup, Emoji, Macro, PandocBib, PlainText, PlantUML, RemoteCode, Render, Sanitize, TOC, Tags, YAML

Constant Summary collapse

PLACEHOLDER_PATTERN =
/%(\S+)%.+=\1=/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#path_to_link_text, #trim_leading_slashes

Constructor Details

#initialize(markup) ⇒ Filter

Setup the object. Sets ‘@markup` to be the instance of Gollum::Markup that is running this filter chain, and sets `@map` to be an empty hash (for use in your extract/process operations).



56
57
58
59
60
61
# File 'lib/gollum-lib/filter.rb', line 56

def initialize(markup)
  @markup = markup
  @map    = {}
  @open_pattern = "%#{self.class.to_s.split('::').last}%"
  @close_pattern = "=#{self.class.to_s.split('::').last}="
end

Instance Attribute Details

#close_patternObject (readonly)

Returns the value of attribute close_pattern.



63
64
65
# File 'lib/gollum-lib/filter.rb', line 63

def close_pattern
  @close_pattern
end

#open_patternObject (readonly)

Returns the value of attribute open_pattern.



63
64
65
# File 'lib/gollum-lib/filter.rb', line 63

def open_pattern
  @open_pattern
end

Instance Method Details

#extract(data) ⇒ Object

Raises:

  • (RuntimeError)


65
66
67
68
# File 'lib/gollum-lib/filter.rb', line 65

def extract(data)
  raise RuntimeError,
        "#{self.class} has not implemented ##extract!"
end

#process(data) ⇒ Object

Raises:

  • (RuntimeError)


70
71
72
73
# File 'lib/gollum-lib/filter.rb', line 70

def process(data)
  raise RuntimeError,
        "#{self.class} has not implemented ##process!"
end