class Luce::BlockParser
- Luce::BlockParser
- Reference
- Object
Overview
Maintains the internal state needed to parse a series of lines into blocks of Markdown suitable for further inline parsing.
Defined in:
luce/block_parser.crConstructors
Instance Method Summary
-
#advance : Nil
Advance the reading position by one line
-
#block_syntaxes : Array(Luce::BlockSyntax)
The enabled block syntaxes
-
#current : Line
Return the current line
-
#current_syntax : BlockSyntax | Nil
The
BlockSyntax
which is running now. -
#document : Document
The Markdown document this parser is parsing
- #done? : Bool
-
#encountered_blank_line : Bool
Whether the parser has encountered a blank line between two block-level elements.
DEPRECATED Use
#encountered_blank_line?
instead. Remove at version 1.0. -
#encountered_blank_line=(encountered_blank_line : Bool)
Whether the parser has encountered a blank line between two block-level elements.
-
#encountered_blank_line? : Bool
Whether the parser has encountered a blank line between two block-level elements.
- #lines : Array(Line)
-
#lines_to_consume : Array(Line)
The lines from
@start
to@pos
(inclusive), it works as a buffer for some blocks, for example: When theParagraphSyntax
parsing process is interrupted by theSetextHeaderSyntax
, so this structure is not a paragraph but a setext heading, then theParagraphSyntax#parse
does not have to retreat the reading position, it only needs to returnnil
, theSetextHeaderSyntax
will pick up the lines in#lines_to_consume
. -
#matches?(regex : Regex) : Bool
Return if the current line matches the given regex or not.
-
#matches_next?(regex : Regex) : Bool
Return if the next line matches the given regex or not.
-
#next : Line | Nil
Return the line after the current one or
nil
if there is none. -
#parent_syntax : BlockSyntax | Nil
The parent
BlockSyntax
when it is running inside a nested syntax. - #parse_lines(parent_syntax : BlockSyntax | Nil = nil, disable_setext_heading : Bool = false) : Array(Node)
-
#peek(lines_ahead : Int32) : Line | Nil
Return the line that is lines_ahead lines ahead of the current one, or
nil
if there is none. -
#previous_syntax : BlockSyntax | Nil
The
BlockSyntax
which is running before the#current_syntax
. -
#retreat : Nil
Retreats the reading position by one line
-
#retreat_by(count : Int32) : Nil
Retreats the reading position by count lines.
-
#setext_heading_disabled? : Bool
Whether the
BlockSyntax
is disabled temporarily. -
#standard_block_syntaxes : Array(Luce::BlockSyntax)
The collection of built-in block parsers
Constructor Detail
Instance Method Detail
The enabled block syntaxes
To turn a series of lines into blocks, each of these will be tried in turn. Order matters here.
The BlockSyntax
which is running now.
The value is nil
until we found the first matched BlockSyntax
.
Whether the parser has encountered a blank line between two block-level elements.
DEPRECATED Use #encountered_blank_line?
instead. Remove at version 1.0.
Whether the parser has encountered a blank line between two block-level elements.
Whether the parser has encountered a blank line between two block-level elements.
The lines from @start
to @pos
(inclusive), it works as a buffer for
some blocks, for example:
When the ParagraphSyntax
parsing process is interrupted by the
SetextHeaderSyntax
, so this structure is not a paragraph but a setext
heading, then the ParagraphSyntax#parse
does not have to retreat the
reading position, it only needs to return nil
, the SetextHeaderSyntax
will pick up the lines in #lines_to_consume
.
The parent BlockSyntax
when it is running inside a nested syntax.
Return the line that is lines_ahead lines ahead of the current
one, or nil
if there is none.
Note that #peek(0)
is equivalent to #current
, and #peek(1)
is
equivalent to #next
.
The BlockSyntax
which is running before the #current_syntax
.