asciidoctor.rb

Path: lib/asciidoctor.rb
Last Update: Wed Jun 28 22:44:43 -0400 2017

encoding: UTF-8

Required files

set   asciidoctor/opal_ext   asciidoctor/version   asciidoctor/timings  

Methods

Constants

RUBY_ENGINE = 'unknown' unless defined? RUBY_ENGINE   encoding: UTF-8
RUBY_ENGINE_OPAL = (RUBY_ENGINE == 'opal')
RUBY_ENGINE_JRUBY = (RUBY_ENGINE == 'jruby')
RUBY_MIN_VERSION_1_9 = (RUBY_VERSION >= '1.9')
RUBY_MIN_VERSION_2 = (RUBY_VERSION >= '2')
UriSniffRx = %r{^#{CG_ALPHA}[#{CC_ALNUM}.+-]+:/{0,2}}   Detects strings that resemble URIs.

Examples

  http://domain
  https://domain
  file:///path
  data:info

  not c:/sample.adoc or c:\sample.adoc
UriTerminator = /[);:]$/   Detects the end of an implicit URI in the text

Examples

  (http://google.com)
  >http://google.com<
  (See http://google.com):
XmlSanitizeRx = /<[^>]+>/   Detects XML tags
INTRINSIC_ATTRIBUTES = { 'startsb' => '[', 'endsb' => ']', 'vbar' => '|', 'caret' => '^', 'asterisk' => '*', 'tilde' => '~', 'plus' => '&#43;', 'backslash' => '\\', 'backtick' => '`', 'blank' => '', 'empty' => '', 'sp' => ' ', 'two-colons' => '::', 'two-semicolons' => ';;', 'nbsp' => '&#160;', 'deg' => '&#176;', 'zwsp' => '&#8203;', 'quot' => '&#34;', 'apos' => '&#39;', 'lsquo' => '&#8216;', 'rsquo' => '&#8217;', 'ldquo' => '&#8220;', 'rdquo' => '&#8221;', 'wj' => '&#8288;', 'brvbar' => '&#166;', 'cpp' => 'C++', 'amp' => '&', 'lt' => '<', 'gt' => '>'   StripLineWise = /\A(?:\s*\n)?(#{CC_ALL}*?)\s*\z/m end
QUOTE_SUBS = { false => quote_subs, true => compat_quote_subs
REPLACEMENTS = [ # (C) [/\\?\(C\)/, '&#169;', :none], # (R) [/\\?\(R\)/, '&#174;', :none], # (TM) [/\\?\(TM\)/, '&#8482;', :none], # foo -- bar # FIXME this drops the endline if it appears at end of line [/(^|\n| |\\)--( |\n|$)/, '&#8201;&#8212;&#8201;', :none], # foo--bar [/(#{CG_WORD})\\?--(?=#{CG_WORD})/, '&#8212;&#8203;', :leading], # ellipsis [/\\?\.\.\./, '&#8230;&#8203;', :leading], # right single quote [/\\?`'/, '&#8217;', :none], # apostrophe (inside a word) [/(#{CG_ALNUM})\\?'(?=#{CG_ALPHA})/, '&#8217;', :leading], # right arrow -> [/\\?-&gt;/, '&#8594;', :none], # right double arrow => [/\\?=&gt;/, '&#8658;', :none], # left arrow <- [/\\?&lt;-/, '&#8592;', :none], # left double arrow <= [/\\?&lt;=/, '&#8656;', :none], # restore entities [/\\?(&)amp;((?:[a-zA-Z]+|#\d{2,5}|#x[a-fA-F0-9]{2,4});)/, '', :bounding]   NOTE in Ruby 1.8.7, [^\] does not match start of line, so we need to match it explicitly order is significant

External Aliases

convert -> render
  Alias render to convert to maintain backwards compatibility
convert_file -> render_file
  Alias render_file to convert_file to maintain backwards compatibility

Public Class methods

Public: Parse the AsciiDoc source input into an Asciidoctor::Document and convert it to the specified backend format.

Accepts input as an IO, String or String Array object. If the input is a File, information about the file is stored in attributes on the Document.

If the :in_place option is true, and the input is a File, the output is written to a file adjacent to the input file, having an extension that corresponds to the backend format. Otherwise, if the :to_file option is specified, the file is written to that file. If :to_file is not an absolute path, it is resolved relative to :to_dir, if given, otherwise the Document#base_dir. If the target directory does not exist, it will not be created unless the :mkdirs option is set to true. If the file cannot be written because the target directory does not exist, or because it falls outside of the Document#base_dir in safe mode, an IOError is raised.

If the output is going to be written to a file, the header and footer are included unless specified otherwise (writing to a file implies creating a standalone document). Otherwise, the header and footer are not included by default and the converted result is returned.

input - the String AsciiDoc source filename options - a String, Array or Hash of options to control processing (default: {})

          String and Array values are converted into a Hash.
          See Asciidoctor::Document#initialize for details about options.

Returns the Document object if the converted String is written to a file, otherwise the converted String

Public: Parse the contents of the AsciiDoc source file into an Asciidoctor::Document and convert it to the specified backend format.

input - the String AsciiDoc source filename options - a String, Array or Hash of options to control processing (default: {})

          String and Array values are converted into a Hash.
          See Asciidoctor::Document#initialize for details about options.

Returns the Document object if the converted String is written to a file, otherwise the converted String

Public: Parse the AsciiDoc source input into a {Document}

Accepts input as an IO (or StringIO), String or String Array object. If the input is a File, information about the file is stored in attributes on the Document object.

input - the AsciiDoc source as a IO, String or Array. options - a String, Array or Hash of options to control processing (default: {})

          String and Array values are converted into a Hash.
          See {Document#initialize} for details about these options.

Returns the Document

Public: Parse the contents of the AsciiDoc source file into an Asciidoctor::Document

Accepts input as an IO, String or String Array object. If the input is a File, information about the file is stored in attributes on the Document.

input - the String AsciiDoc source filename options - a String, Array or Hash of options to control processing (default: {})

          String and Array values are converted into a Hash.
          See Asciidoctor::Document#initialize for details about options.

Returns the Asciidoctor::Document

[Validate]