|
|
|
@ -6,11 +6,13 @@ use utf8;
|
|
|
|
|
|
|
|
|
|
my $SP = '[\ \t]'; |
|
|
|
|
my $EOL = '\r?\n'; |
|
|
|
|
my $TAIL = '(?:^\s*$)*'; |
|
|
|
|
our $regexps = {}; |
|
|
|
|
|
|
|
|
|
$regexps->{header} = qr{ |
|
|
|
|
^ (?<header> .+ ) $EOL |
|
|
|
|
^ (?<line> [=-]+ ) (?: $EOL | $) |
|
|
|
|
$TAIL |
|
|
|
|
}mx; |
|
|
|
|
|
|
|
|
|
$regexps->{codeblock} = qr% |
|
|
|
@ -39,6 +41,7 @@ $SP? # maybe one leading space
|
|
|
|
|
</\g{tag}> # the same tag as in first line |
|
|
|
|
$SP* # maybe any number of trailing spaces |
|
|
|
|
(?: $EOL | $) # end of last line |
|
|
|
|
$TAIL # one or more empty lines |
|
|
|
|
%mx; |
|
|
|
|
|
|
|
|
|
$regexps->{table} = qr/ |
|
|
|
@ -53,6 +56,7 @@ $regexps->{table} = qr/
|
|
|
|
|
(?: $EOL | $ ) # newline or file end |
|
|
|
|
)+ # one or more such lines |
|
|
|
|
) |
|
|
|
|
$TAIL # one or more empty lines |
|
|
|
|
/mx; |
|
|
|
|
|
|
|
|
|
$regexps->{pre} = qr/ |
|
|
|
@ -64,6 +68,7 @@ $regexps->{pre} = qr/
|
|
|
|
|
(?: $EOL | $ ) # newline or file end |
|
|
|
|
)+ # one or more lines |
|
|
|
|
) |
|
|
|
|
$TAIL # one or more empty lines |
|
|
|
|
/mx; |
|
|
|
|
|
|
|
|
|
$regexps->{blockquote} = qr/ |
|
|
|
@ -76,6 +81,7 @@ $regexps->{blockquote} = qr/
|
|
|
|
|
(?: $EOL | $ ) # newline or file end |
|
|
|
|
)+ # one or more lines |
|
|
|
|
) |
|
|
|
|
$TAIL # one or more empty lines |
|
|
|
|
/mx; |
|
|
|
|
|
|
|
|
|
$regexps->{list} = qr/ |
|
|
|
@ -88,6 +94,7 @@ $regexps->{list} = qr/
|
|
|
|
|
(?: $EOL | $ ) # newline or file end |
|
|
|
|
)+ # one or more lines |
|
|
|
|
) |
|
|
|
|
$TAIL # one or more empty lines |
|
|
|
|
/mx; |
|
|
|
|
|
|
|
|
|
1; |
|
|
|
|