Skip to content

Commit 59ce4aa

Browse files
committed
various fixes in wiki2markdown.pl.
1 parent f3cea16 commit 59ce4aa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

wiki2markdown.pl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ ($)
175175
} else {
176176
undef $lang;
177177
}
178-
if ($v =~ /^ {0,3}\S/m) { $v =~ s/^/ /gm }
178+
if ($v =~ /^ {0,3}\S/ms) {
179+
$v =~ s/^/ /gms;
180+
}
179181
my $out = "\n$v";
180182
if ($lang) {
181183
$out = "```$lang\n$out```";
@@ -229,7 +231,7 @@ ($)
229231

230232
while ($s =~ s{^(\S[^\n]*?)?([^\(\<\n])(https?://[^\s)(\n]+)}{$1$2<$3>}gms) {}
231233
#$s =~ s{^\[\[(\w+)\]\]}{my $name = $1; my $link = gen_link($name); warn "!!! $name"; defined($link) ? "[$name]($link)" : "[$name](http://wiki.nginx.org/$name)"}gsme;
232-
while ($s =~ s{^(\S[^\n]*?)\[\[(\w+)\]\]}{
234+
while ($s =~ s{^(\S[^\n]*?)?\[\[(\w+|".*?")\]\]}{
233235
my ($prefix, $name) = ($1, $2);
234236
my ($link, $modname) = gen_link($name);
235237
if (!defined $link) {
@@ -278,7 +280,8 @@ ($)
278280

279281
$s =~ s{^```(\w+)\n(.*?)^```\n}{
280282
my ($lang, $out) = ($1, $2);
281-
$out =~ s/^ //gm;
283+
$out =~ s/^ / /gms;
284+
$out =~ s/ +$//gms;
282285
"```$lang\n" . $out . "```\n"
283286
}gesm;
284287

@@ -294,6 +297,8 @@ ($)
294297
$toc
295298
}egms;
296299

300+
while ($s =~ s{^(\S[^\n]*?)\[(\w+)\](?![\(`])}{$1\\[$2\\]}gms) {}
301+
297302
print "<!---\nDon't edit this file manually! Instead you should generate it ",
298303
"by using:\n wiki2markdown.pl $infile\n-->\n\n";
299304
print $s;

0 commit comments

Comments
 (0)