Module: Jekyll::AsciiDoc::Filters

Defined in:
lib/jekyll-asciidoc/filters.rb

Instance Method Summary collapse

Instance Method Details

#asciidocify(input, doctype = nil) ⇒ String

A Liquid filter for converting an AsciiDoc string to HTML using Converter#convert.

Examples:

Convert the AsciiDoc page excerpt to inline HTML

{{ page.excerpt | asciidocify: 'inline' }}

Parameters:

  • input (String)

    the AsciiDoc String to convert.

  • doctype (String) (defaults to: nil)

    the target AsciiDoc doctype.

Returns:

  • (String)

    the converted result as an HTML-formatted String.



13
14
15
16
# File 'lib/jekyll-asciidoc/filters.rb', line 13

def asciidocify input, doctype = nil
  (@context.registers[:cached_asciidoc_converter] ||= (Converter.get_instance @context.registers[:site]))
    .convert(doctype ? %(:doctype: #{doctype}#{Utils::NewLine}#{input}) : (input || ''))
end

#tocify_asciidoc(document, levels = nil) ⇒ String

A Liquid filter for generating an HTML table of contents from a parsed AsciiDoc document.

contents. attribute.

Examples:

Generate a table of contents from the document for the current page

{{ page.document | tocify_asciidoc: 3 }}

Parameters:

  • document (Asciidoctor::Document)

    the parsed AsciiDoc document for which to generate an HTML table of

  • levels (Integer) (defaults to: nil)

    the maximum section depth to use; if not specified, uses the value of toclevels document

Returns:

  • (String)

    the table of contents as an HTML-formatted String.



29
30
31
32
# File 'lib/jekyll-asciidoc/filters.rb', line 29

def tocify_asciidoc document, levels = nil
  ::Asciidoctor::Document === document ?
    (document.converter.convert document, 'outline', toclevels: (levels.nil_or_empty? ? nil : levels.to_i)) : nil
end