class Luce::DelimiterRun
- Luce::DelimiterRun
- Luce::Delimiter
- Reference
- Object
Overview
An implementation of Delimiter
which uses concepts of
"left-flanking" and "right-flanking" to determine the values of
#openable?
and closeable?
.
This is primarily used when parsing emphasis and strong emphasis,
but can also be used by other extensions of DelimiterSyntax
.
Defined in:
luce/inline_syntaxes/delimiter_syntax.crConstructors
Class Method Summary
-
.parse?(parser : InlineParser, run_start : Int32, run_end : Int32, syntax : DelimiterSyntax, tags : Array(DelimiterTag), node : Text, allow_intra_word : Bool = false) : DelimiterRun | Nil
Attempt to parse a delimiter run from run_start (inclusive) to run_end (exclusive).
-
.punctuation : Regex
According to CommonMark:
-
.whitespace : String
TODO Unicode whitespace
Instance Method Summary
-
#active=(active : Bool) : Nil
Whether the delimiter is active
-
#active? : Bool
Whether the delimiter is active
- #allow_intra_word? : Bool
-
#char : Int32
The type of delimiter
-
#closable? : Bool
Whether this delimiter can close emphasis or strong emphasis.
-
#node : Text
The
Text
ndoe representing the plain text representing this delimiter -
#node=(node : Text)
The
Text
ndoe representing the plain text representing this delimiter -
#openable? : Bool
Whether this delimiter can open emphasis or strong emphasis.
-
#size : Int32
The number of delimiters
-
#syntax : DelimiterSyntax
The syntax which uses this delimiter to parse a tag.
- #tags : Array(DelimiterTag)
-
#to_s : String
Returns a nicely readable and concise string representation of this object, typically intended for users.
Instance methods inherited from class Luce::Delimiter
active=(active : Bool) : Nil
active=,
active? : Bool
active?,
char : Int32
char,
closable? : Bool
closable?,
node : Text
node,
node=(node : Text)
node=,
openable? : Bool
openable?,
size : Int32
size,
syntax : DelimiterSyntax
syntax
Constructor Detail
Class Method Detail
Attempt to parse a delimiter run from run_start (inclusive) to run_end (exclusive).
According to CommonMark:
A punctuation character is an ASCII punctuation character or anything in the general Unicode categories
Pc
,Pd
,Pe
,Pf
,Pi
,Po
, orPs
.
This Regex is inspired by https://github.com/commonmark/commonmark.js/blob/1f7d09099/lib/inlines.js#L39. I don't know if there is any way to simplify it or maintain it.
Instance Method Detail
Whether the delimiter is active
Links cannot be nested, so we must "deactivate" any pending ones. For example, take the following text:
Text [link and [more](links)](links).
Once we have parsed Text [
, there is one (pending) link in the
state stack. It is, by default, active. Once we parse the next
possible link, [more](links)
, as a real link, we must
deactivate the pending links (just the one, in this case).
Whether the delimiter is active
Links cannot be nested, so we must "deactivate" any pending ones. For example, take the following text:
Text [link and [more](links)](links).
Once we have parsed Text [
, there is one (pending) link in the
state stack. It is, by default, active. Once we parse the next
possible link, [more](links)
, as a real link, we must
deactivate the pending links (just the one, in this case).
The type of delimiter
For the two-character image delimiter, ![
, this is !
.
Whether this delimiter can close emphasis or strong emphasis.
The Text
ndoe representing the plain text representing this
delimiter
The Text
ndoe representing the plain text representing this
delimiter
Whether this delimiter can open emphasis or strong emphasis.
The syntax which uses this delimiter to parse a tag.
Returns a nicely readable and concise string representation of this object, typically intended for users.
This method should usually not be overridden. It delegates to
#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.