The sub processors called bepends on the length of the delimiter run. All child processors must have different minimum lengths. A given delimiter run is dispatched to the child with the largest acceptable minimum length. If not child is applicable, the one with the largest minimum length is chosen.
markdown2 :: MdStaggeredDelimiterProcessor :: add
Add a new sub delimiter processormarkdown2 :: MdStaggeredDelimiterProcessor :: delim=
Delimiter charactermarkdown2 :: MdStaggeredDelimiterProcessor :: find_processor
Find the corresponding processor for a length oflen
delimiter characters
markdown2 :: MdStaggeredDelimiterProcessor :: processors
Sub processors to applymarkdown2 :: MdStaggeredDelimiterProcessor :: processors=
Sub processors to applymarkdown2 $ MdStaggeredDelimiterProcessor :: SELF
Type of this instance, automatically specialized in every classmarkdown2 $ MdStaggeredDelimiterProcessor :: closing_delimiter
The character that marks the ending of a delimited nodemarkdown2 $ MdStaggeredDelimiterProcessor :: delimiter_use
Determine how many (if any) of the delimiter characters should be usedmarkdown2 $ MdStaggeredDelimiterProcessor :: min_length
Minimum number of delimiters characters that are needed to active thismarkdown2 $ MdStaggeredDelimiterProcessor :: opening_delimiter
The character that marks the beginning of a delimited nodemarkdown2 :: MdStaggeredDelimiterProcessor :: add
Add a new sub delimiter processorcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
markdown2 :: MdDelimiterProcessor :: closing_delimiter
The character that marks the ending of a delimited nodecore :: Object :: defaultinit
markdown2 :: MdStaggeredDelimiterProcessor :: delim=
Delimiter charactermarkdown2 :: MdDelimiterProcessor :: delimiter_use
Determine how many (if any) of the delimiter characters should be usedmarkdown2 :: MdStaggeredDelimiterProcessor :: find_processor
Find the corresponding processor for a length oflen
delimiter characters
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
markdown2 :: MdDelimiterProcessor :: min_length
Minimum number of delimiters characters that are needed to active thismarkdown2 :: MdDelimiterProcessor :: opening_delimiter
The character that marks the beginning of a delimited nodecore :: Object :: output_class_name
Display class name on stdout (debug only).markdown2 :: MdStaggeredDelimiterProcessor :: processors
Sub processors to applymarkdown2 :: MdStaggeredDelimiterProcessor :: processors=
Sub processors to applymarkdown2 :: MdDelimiterProcessor
Custom delimiter processor for additional delimiters besides_
and *
# An implementation of MdDelimiterProcessor that dispatches all calls to others
#
# The sub processors called bepends on the length of the delimiter run.
# All child processors must have different minimum lengths.
# A given delimiter run is dispatched to the child with the largest acceptable minimum length.
# If not child is applicable, the one with the largest minimum length is chosen.
class MdStaggeredDelimiterProcessor
super MdDelimiterProcessor
# Delimiter character
var delim: Char
# Sub processors to apply
var processors = new Array[MdDelimiterProcessor]
redef var min_length = 0
redef fun opening_delimiter do return delim
redef fun closing_delimiter do return delim
# Add a new sub delimiter processor
fun add(dp: MdDelimiterProcessor) do
var len = dp.min_length
var i = 0
while i < processors.length do
var p = processors[i]
assert len != p.min_length else
print "Cannot add two delimiter processor for `{delim}` " +
"and mininimum length `{len}`"
end
if len > p.min_length then
break
end
i += 1
end
processors.insert(dp, i)
end
# Find the corresponding processor for a length of `len` delimiter characters
fun find_processor(len: Int): MdDelimiterProcessor do
for processor in processors do
if processor.min_length <= len then return processor
end
return processors.first
end
redef fun delimiter_use(opener, closer) do
return find_processor(opener.length).delimiter_use(opener, closer)
end
redef fun process(opener, closer, delimiter_use) do
find_processor(delimiter_use).process(opener, closer, delimiter_use)
end
end
lib/markdown2/markdown_inline_parsing.nit:1242,1--1294,3