wikiheaders.pl: Fix some wordwrap whitespace issues.

This commit is contained in:
Ryan C. Gordon 2021-07-14 10:03:31 -04:00
parent 04196a46a5
commit bab0eb71ce
No known key found for this signature in database
GPG Key ID: FA148B892AB48044

View File

@ -28,11 +28,15 @@ sub wordwrap_with_bullet_indent { # don't call this directly.
my $str = shift; my $str = shift;
my $retval = ''; my $retval = '';
#print("WORDWRAP BULLET ('$bullet'):\n\n$str\n\n");
# You _can't_ (at least with Pandoc) have a bullet item with a newline in # You _can't_ (at least with Pandoc) have a bullet item with a newline in
# MediaWiki, so _remove_ wrapping! # MediaWiki, so _remove_ wrapping!
if ($wordwrap_mode eq 'mediawiki') { if ($wordwrap_mode eq 'mediawiki') {
$retval = "$bullet$str"; $retval = "$bullet$str";
$retval =~ s/\n/ /gms; $retval =~ s/\n/ /gms;
$retval =~ s/\s+$//gms;
#print("WORDWRAP BULLET DONE:\n\n$retval\n\n");
return "$retval\n"; return "$retval\n";
} }
@ -105,6 +109,8 @@ sub wordwrap {
#print("\n\nWORDWRAP:\n\n$str\n\n\n"); #print("\n\nWORDWRAP:\n\n$str\n\n\n");
$str =~ s/\A\n+//ms;
while ($str =~ s/(.*?)(\`\`\`.*?\`\`\`|\<syntaxhighlight.*?\<\/syntaxhighlight\>)//ms) { while ($str =~ s/(.*?)(\`\`\`.*?\`\`\`|\<syntaxhighlight.*?\<\/syntaxhighlight\>)//ms) {
#print("\n\nWORDWRAP BLOCK:\n\n$1\n\n ===\n\n$2\n\n\n"); #print("\n\nWORDWRAP BLOCK:\n\n$1\n\n ===\n\n$2\n\n\n");
$retval .= wordwrap_paragraphs($1); # wrap it. $retval .= wordwrap_paragraphs($1); # wrap it.