Class: Coradoc::AsciiDoc::Parser::Base

Inherits:
Parslet::Parser
  • Object
show all
Includes:
Model::Block, Model::Inline, Model::List, BlockHeader, Citation, Content, Stem, Text, Model::Admonition, Model::AttributeList, Model::Bibliography, Model::DocumentAttributes, Model::Header, Model::Paragraph, Model::Section, Model::Table, Model::Term
Defined in:
lib/coradoc/asciidoc/parser/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Stem

#stem, #stem_type

Methods included from Text

#attr_name, #block_image, #comment_block, #comment_line, #date, #digit, #digits, #email, #empty_line, #endline, #eof?, #file_path, #include_directive, #keyword, #line_end, #line_ending, #line_start?, #newline, #newline_single, #rich_text, #rich_texts, #space, #space?, #special_character, #tag, #text, #word, #words

Methods included from Content

#asciidoc_char, #asciidoc_char_with_id, #element_id, #element_id_inline, #glossaries, #glossary, #list_prefix, #literal_space, #literal_space?, #page_break, #text_line

Methods included from Citation

#cross_reference, #xref_anchor, #xref_arg, #xref_str

Methods included from BlockHeader

#attribute_blocks, #block_header

Class Method Details

.parse(string) ⇒ Hash

Parse an AsciiDoc string

Parameters:

  • string (String)

    The Asciidoc string to parse

Returns:

  • (Hash)

    The parsed AST object



82
83
84
85
86
# File 'lib/coradoc/asciidoc/parser/base.rb', line 82

def self.parse(string)
  new.parse(string)
rescue Parslet::ParseFailed => e
  warn e.parse_failure_cause.ascii_tree
end

.parse_file(filename) ⇒ Hash

Parse an AsciiDoc file

Parameters:

  • filename (String)

    The filename of the Asciidoc file to parse

Returns:

  • (Hash)

    The parsed AST object



75
76
77
# File 'lib/coradoc/asciidoc/parser/base.rb', line 75

def self.parse_file(filename)
  parse(File.read(filename))
end

Instance Method Details

#rule_dispatch(rule_name) ⇒ Object



88
89
90
# File 'lib/coradoc/asciidoc/parser/base.rb', line 88

def rule_dispatch(rule_name, *, **)
  RuleDispatcher.dispatch(self, rule_name, *, **)
end