Class: NanDoc::Filters::CustomTag

Inherits:
Object
  • Object
show all
Includes:
TagParsingInstanceMethods
Defined in:
lib/nandoc/filters/tag-parser.rb,
lib/nandoc/filters/custom-tag.rb

Overview

we are just (re) opening this class

Defined Under Namespace

Classes: TagParser

Instance Method Summary collapse

Constructor Details

#initializeCustomTag

Returns a new instance of CustomTag.



8
9
# File 'lib/nandoc/filters/custom-tag.rb', line 8

def initialize
end

Instance Method Details

#get_failure_lines(md) ⇒ Object



36
37
38
# File 'lib/nandoc/filters/custom-tag.rb', line 36

def get_failure_lines md
  @last_failure_lines
end

#nameObject



10
11
12
# File 'lib/nandoc/filters/custom-tag.rb', line 10

def name
  @name || 'anonymous custom filter'
end

#render_block(filter, md) ⇒ Object



39
40
41
# File 'lib/nandoc/filters/custom-tag.rb', line 39

def render_block filter, md
  fail("this is the one you want to implement. look at @last_tree maybe.")
end

#wants?(md) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/nandoc/filters/custom-tag.rb', line 17

def wants? md
  tp = tag_parser
  ret = nil
  if ! tp
    ret = false
    @last_failure_lines = ["#{name} doesn't want #{md[:content].inspect}"]
  else
    if tree = tp.parse(md[:content])
      ret = true
      @last_tree = tree
    else
      ret = false
      these = tp.failure_lines(md[:content])
      these.unshift("#{name} couldn't parse tag:")
      @last_failure_lines = these
    end
  end
  ret
end