|
|
@ -1,5 +1,8 @@ |
|
|
|
package Display::Markup; |
|
|
|
|
|
|
|
use strict; |
|
|
|
use warnings; |
|
|
|
|
|
|
|
use base qw(Exporter); |
|
|
|
our @EXPORT_OK = qw(line_parse); |
|
|
|
|
|
|
@ -50,16 +53,16 @@ Parses some special markup, specifically: |
|
|
|
sub line_parse { |
|
|
|
my ($everything, $file) = (@_); |
|
|
|
|
|
|
|
# take care of wala markup |
|
|
|
# Take care of wala markup: |
|
|
|
$everything =~ s/<wala>(.*?)<\/wala>/Wala::wikify($1)/seg; |
|
|
|
|
|
|
|
# take care of textile markup, if we've got any |
|
|
|
# Take care of textile markup, if we've got any: |
|
|
|
textile_process($everything); |
|
|
|
|
|
|
|
# evaluate <gallery> tags. |
|
|
|
# Evaluate <gallery> tags: |
|
|
|
$everything =~ s!<gallery>(.*?)</gallery>!gallery_markup($file, $1)!seg; |
|
|
|
|
|
|
|
# evaluate <image> tags. |
|
|
|
# Evaluate <image> tags: |
|
|
|
$everything =~ s!<image>(.*?)</image>!image_markup($file, $1)!seg; |
|
|
|
|
|
|
|
foreach my $key (keys %tags) { |
|
|
@ -70,26 +73,27 @@ sub line_parse { |
|
|
|
$dashes{$key} = " -- " unless $dashes{$key}; |
|
|
|
|
|
|
|
while ($everything =~ m/(<$key>.*?<\/$key>)/s) { |
|
|
|
|
|
|
|
my $block = $1; |
|
|
|
|
|
|
|
# save the bits between instances of the block -- |
|
|
|
# Save the bits between instances of the block: |
|
|
|
my (@interstice_array) = split /\Q$block\E/s, $everything; |
|
|
|
|
|
|
|
# now, transform the contents of the block we've found: |
|
|
|
# Transform the contents of the block: |
|
|
|
|
|
|
|
# tags that surround the block |
|
|
|
# Tags that surround the block: |
|
|
|
$block =~ s/\n?<$key>\n?/<$tags{$key}>/gs; |
|
|
|
$block =~ s!\n?</$key>\n?!</$end_tags{$key}>!gs; |
|
|
|
|
|
|
|
# dashes |
|
|
|
# Dashes: |
|
|
|
$block = dashes($dashes{$key}, $block); |
|
|
|
|
|
|
|
# blank lines within the block |
|
|
|
# Blank lines within the block: |
|
|
|
$block =~ s/\n\n/$blank_lines{$key}/gs; |
|
|
|
|
|
|
|
$block = newlines($newlines{$key}, $block); |
|
|
|
|
|
|
|
# and slap it all back together as $everything |
|
|
|
# ...and slap it all back together as $everything |
|
|
|
$everything = join $block, @interstice_array; |
|
|
|
|
|
|
|
} |
|
|
@ -101,18 +105,18 @@ sub line_parse { |
|
|
|
sub newlines { |
|
|
|
my ($replacement, $block) = @_; |
|
|
|
|
|
|
|
# single newlines (i.e., line ends) within the block |
|
|
|
# Single newlines (i.e., line ends) within the block, |
|
|
|
# except those preceded by a double-quote, which probably |
|
|
|
# indicates a still-open tag: |
|
|
|
|
|
|
|
$block =~ s/(?<=[^"\n]) # not a double-quote or newline |
|
|
|
# don't capture |
|
|
|
$block =~ s/(?<=[^"\n]) # not a double-quote or newline |
|
|
|
# don't capture |
|
|
|
|
|
|
|
\n # end-of-line |
|
|
|
\n # end-of-line |
|
|
|
|
|
|
|
(?=[^\n]) # not a newline |
|
|
|
# don't capture |
|
|
|
/$replacement/xgs; |
|
|
|
(?=[^\n]) # not a newline |
|
|
|
# don't capture |
|
|
|
/$replacement/xgs; |
|
|
|
|
|
|
|
return $block; |
|
|
|
|
|
|
|