Method: JsDuck::Inline::Example#replace

Defined in:
lib/jsduck/inline/example.rb

#replace(input) ⇒ Object

Takes StringScanner instance.

Looks for “<pre><code>@example” at the current scan pointer position, when found, moves scan pointer forward and performs the apporpriate replacement.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jsduck/inline/example.rb', line 26

def replace(input)
  if input.check(@re)
    # Match possible classnames following @example and add them
    # as CSS classes inside <pre> element.
    input.scan(@re) =~ @re
    css_classes = ($1 || "").strip

    return "<pre class='inline-example #{css_classes}'><code>"
  else
    false
  end
end