From 7183e6ad49277cb19fa82ec76c7a9ff3c6984df8 Mon Sep 17 00:00:00 2001 From: david <> Date: Sun, 13 Jan 2002 18:45:54 +0000 Subject: [PATCH] allow spaces between = marks and titles --- LDP/txt2db/txt2db.pl | 64 +++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/LDP/txt2db/txt2db.pl b/LDP/txt2db/txt2db.pl index 89e77b85..7557d08c 100755 --- a/LDP/txt2db/txt2db.pl +++ b/LDP/txt2db/txt2db.pl @@ -117,45 +117,7 @@ sub proc_txt { next; } - # handle whitespace gracefully - while ($line =~ /^= /) { - $line =~ s/^= /^=/; - } - while ($line =~ /^== /) { - $line =~ s/^== /^==/; - } - while ($line =~ /^=== /) { - $line =~ s/^=== /^===/; - } - while ($line =~ / =$/) { - $line =~ s/ =$/=$/; - } - while ($line =~ / ==$/) { - $line =~ s/ ==$/==$/; - } - while ($line =~ / ===$/) { - $line =~ s/ ===$/===$/; - } - - if ($line =~ /^=\w/) { - &close1; - &splittitle; - if ($id eq '') { - $line = "$title\n"; - } else { - $line = "$title\n"; - } - $level1 = 1; - } elsif ($line =~ /^==\w/) { - &close2; - &splittitle; - if ($id eq '') { - $line = "$title\n"; - } else { - $line = "$title\n"; - } - $level2 = 1; - } elsif ($line =~ /^===\w/) { + if ($line =~ /^===/) { &close3; &splittitle; if ($id eq '') { @@ -164,6 +126,24 @@ sub proc_txt { $line = "$title\n"; } $level3 = 1; + } elsif ($line =~ /^==/) { + &close2; + &splittitle; + if ($id eq '') { + $line = "$title\n"; + } else { + $line = "$title\n"; + } + $level2 = 1; + } elsif ($line =~ /^=/) { + &close1; + &splittitle; + if ($id eq '') { + $line = "$title\n"; + } else { + $line = "$title\n"; + } + $level1 = 1; } elsif ($line =~ /^#/) { if ($orderedlist == 0) { $buf .= "\n\n"; @@ -305,4 +285,10 @@ sub splittitle { $id = $line; $id =~ s/^.+\|//; } + while ($title =~ /^\ /) { + $title =~ s/^\ //; + } + while ($title =~ /\ $/) { + $title =~ s/\ $//; + } }