Currently handles lists and pre blocks including nested lists of mixed type.
See /StreamlinedTextFormattingTestPage for examples.
Now I just need to get tables working and this bit will become a replacement for function WikiLinesToHtml.
$_ .= "\n"; # Append blank line for markup purposes. my %map = ( '*' => {code => "ul", line => "<li>"}, '#' => {code => "ol", line => "<li>"}, ';' => {code => "dl", line => "<dt>"}, ':' => {code => "dl", line => "<dt><dd>"}, '.' => {code => "pre"}, # '||' => {code => "table border=1", line => "<tr><td>"} '|' => {tagin => "<table border=1>", tagout => "</table>"}, '+' => {code => "tr"}, '_' => {code => "td"} ); map { $map{$_}{tagin} = "<" . $map{$_}{code} . ">" if exists $map{$_}{code}; $map{$_}{tagout} = "</" . $map{$_}{code} . ">" if exists $map{$_}{code}; $map{$_}{line} = "" if not exists $map{$_}{line}; } (keys %map); # Tag matching expression. my $tags = "[*#;:." . (($TableSyntax) ? "|_+" : "") . "]"; # $tags = "(?:(?:\\|\\|)|$tags)" if $TableSyntax; # Special Handling for Description Lists. s/^($tags*?);(.*):/\1;\2<dd>/mgo; # Special Handling for PRE blocks, which do not nest. # Prepend new '.' tag to these lines. s/^([ \t])/\.\1/mg; # Special Handling for Table markup. # Lines ending with || end the table row. #s/\|\|\s*\n/<\/td><\/tr>\n/mg if $TableSyntax; # Remove Lines ending with ||. s/\|\|\s*\n/\n/mg if $TableSyntax; # This expands the line tags into their HTML equivalents. # Only need to do rightmost tags. # Leaves the tags in place for the next instruction. s/^($tags*)($tags)/$1$2$map{$2}{line}/mgo; # This adds the parent tags around each whole list. # Loops round to maximum level of nested lists + 1. # Second substitute removes tags on each iteration. my $t; 1 while s/ ^($tags) # Line Tag. (.*?\n) # Rest of Tagged Line. (((\1.*?\n))*) # Multiple lines with same tag. /$map{$1}{tagin}\n$1$2$3$map{$1}{tagout}\n/mgox && s/^$tags(.*?\n)/$1/smog; # Remove line tag.