Path: | lib/asciidoctor.rb |
Last Update: | Wed Jun 28 22:44:43 -0400 2017 |
encoding: UTF-8
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' => '+', 'backslash' => '\\', 'backtick' => '`', 'blank' => '', 'empty' => '', 'sp' => ' ', 'two-colons' => '::', 'two-semicolons' => ';;', 'nbsp' => ' ', 'deg' => '°', 'zwsp' => '​', 'quot' => '"', 'apos' => ''', 'lsquo' => '‘', 'rsquo' => '’', 'ldquo' => '“', 'rdquo' => '”', 'wj' => '⁠', 'brvbar' => '¦', '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\)/, '©', :none], # (R) [/\\?\(R\)/, '®', :none], # (TM) [/\\?\(TM\)/, '™', :none], # foo -- bar # FIXME this drops the endline if it appears at end of line [/(^|\n| |\\)--( |\n|$)/, ' — ', :none], # foo--bar [/(#{CG_WORD})\\?--(?=#{CG_WORD})/, '—​', :leading], # ellipsis [/\\?\.\.\./, '…​', :leading], # right single quote [/\\?`'/, '’', :none], # apostrophe (inside a word) [/(#{CG_ALNUM})\\?'(?=#{CG_ALPHA})/, '’', :leading], # right arrow -> [/\\?->/, '→', :none], # right double arrow => [/\\?=>/, '⇒', :none], # left arrow <- [/\\?<-/, '←', :none], # left double arrow <= [/\\?<=/, '⇐', :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 |
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: 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