If it was preceded by two spaces, return a hard line break, otherwise a soft line break
# Parse a new line
#
# If it was preceded by two spaces, return a hard line break,
# otherwise a soft line break
private fun parse_newline: Bool do
advance 1 # assume we're at a `\n`
var last_child = block.last_child
# check previous text for trailing spaces
# the `has_suffix` is an optimization to avoid an RE match in the common case
if last_child != null and last_child isa MdText and
(last_child.literal.has_suffix(" ")) then
var text = last_child
var literal = text.literal
var match = literal.search(re_final_space)
var spaces = if match != null then match.length else 0
if spaces > 0 then
text.literal = literal.substring(0, literal.length - spaces)
end
last_child.location.column_end = last_child.location.column_end - spaces
if spaces >= 2 then
append_node(new MdHardLineBreak(new MdLocation(line, column - spaces - 1, line, column - 1), false))
else
append_node(new MdSoftLineBreak(new MdLocation(line, column - spaces - 1, line, column -1)))
end
else
append_node(new MdSoftLineBreak(new MdLocation(line, column - 1, line, column - 1)))
end
line += 1
column = 1 + column_offset
# gobble leading spaces in next line
while peek == ' ' do
advance 1
end
return true
end
lib/markdown2/markdown_inline_parsing.nit:334,2--371,4