delimiter_char
Return information about the number of delimiters and whether they are positioned such as they can open and/or close emphasis or strong emphasis.
# Scan a sequence of characters with code `delimiter_char`
#
# Return information about the number of delimiters and whether they are positioned
# such as they can open and/or close emphasis or strong emphasis.
private fun scan_delimiters(delimiter_processor: MdDelimiterProcessor, delimiter_char: Char): nullable MdDelimiterData do
var start_index = index
var start_column = column
var delimiter_count = 0
while peek == delimiter_char do
delimiter_count += 1
advance 1
end
if delimiter_count < delimiter_processor.min_length then
index = start_index
column = start_column
return null
end
var before = "\n"
if start_index > 0 then
before = input.substring(start_index - 1, 1)
end
var char_after = peek
var after = "\n"
if char_after != '\0' then
after = char_after.to_s
end
var before_is_punctuation = before.has(re_punctuation)
var before_is_whitespace = before.has(re_whitespace_char)
var after_is_punctuation = after.has(re_punctuation)
var after_is_whitespace = after.has(re_whitespace_char)
var left_flanking = not after_is_whitespace and
(not after_is_punctuation or before_is_whitespace or before_is_punctuation)
var right_flanking = not before_is_whitespace and
(not before_is_punctuation or after_is_whitespace or after_is_punctuation)
var can_open
var can_close
if delimiter_char == '_' then
can_open = left_flanking and (not right_flanking or before_is_punctuation)
can_close = right_flanking and (not left_flanking or after_is_punctuation)
else
can_open = left_flanking and delimiter_char == delimiter_processor.opening_delimiter
can_close = right_flanking and delimiter_char == delimiter_processor.closing_delimiter
end
index = start_index
column = start_column
return new MdDelimiterData(delimiter_count, can_open, can_close)
end
lib/markdown2/markdown_inline_parsing.nit:852,2--906,4