Browse Source

Markdown.pl: add more list start heuristics

In b62cef825e (Markdown.pl: recognize top-level lists better,
2017-01-09, markdown_1.1.0), an attempt was made to recognize
obvious lists that were improperly being treated as wrapped paragraphs.

While that change offers a number of improvements (i.e. more lists
are recognized properly than were before), it does not go far enough.

Further enhance it to only require a single list marker to start a
list provided it's one of the unordered list markers.  While it's
certainly possible that a lone "*", "+" or "-" got wrapped onto the
beginning of a line by itself, it's easy to correct; since lone
occurrences of those characters seems highly unlikely, choose the
list starting interpretation instead.

In addition, if the prior line ends with a colon (:) do not require
two markers to start the list, just one.

Furthermore, allow a single, optional, blank line between two markers
that do start a list.

With these changes, the vast majority of lists are recognized properly.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
master
Kyle J. McKay 5 years ago
parent
commit
ec42c098cb
  1. 12
      Markdown.pl

12
Markdown.pl

@ -1722,14 +1722,14 @@ sub _DoLists {
$text =~ s{
(?: (?<=\n\n) |
\A\n? |
(?:(?<=\n) # two of the same kind of marker lines
(?=[ ]{0,$less_than_indent}$marker_ul[ ].*\n
[ ]{0,$less_than_indent}$marker_ul[ ])) |
(?:(?<=\n) # in a row will start a list
(?=[ ]{0,$less_than_indent}$marker_ol[ ].*\n
(?<=:\n) |
(?:(?<=\n) # a list starts with one unordered marker line
(?=[ ]{0,$less_than_indent}$marker_ul[ ])) |
(?:(?<=\n) # or two ordered marker lines in a row
(?=[ ]{0,$less_than_indent}$marker_ol[ ].*\n\n?
[ ]{0,$less_than_indent}$marker_ol[ ])) |
(?:(?<=\n) # or any marker and a sublist marker
(?=[ ]{0,$less_than_indent}$marker_any[ ].*\n
(?=[ ]{0,$less_than_indent}$marker_any[ ].*\n\n?
[ ]{$indent,$less_than_double_indent}$marker_any[ ]))
)
$whole_list

Loading…
Cancel
Save