103 件 見つかりました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [ 次へ ]
- a -- aa -- ab --- aba -- ac - b - c -- ca
- a
- aa
- ab
- aba
- ac
- b
- c
- ca
[ul]
- a
- aa
bbb
- ac
- b
bbb
- c
[/ul]
#!/usr/bin/env perl
use strict;
use warnings;
my $str = join("", <>);
$str =~ s{\[ul\](.+?)\[/ul\]}{make_ul_list_html($1)}gmse;
print $str;
sub make_ul_list_html {
my ($str) = @_;
my $new_str = "";
if ($str =~ m/^(-+|^ *-) /ms) {
my $hd = $1;
while ($str =~ m{^($hd .+?)(?=(^$hd |\z))}gms) {
my $item_con = $1;
$item_con =~ s{^$hd (.+?)(?=(^-+|^ *-|\z))}{}ms;
my $item_str = $1;
chomp $item_con;
chomp $item_str;
# $item_str =~ s{^\s+}{}gm; # 字下げスペース削除
$new_str .= "<li>$item_str"
.make_ul_list_html($item_con)."</li>\n";
}
}
return $new_str ? "\n<ul>\n$new_str</ul>\n" : $str;
}
hello
[ul]
- a
<pre>
abab
ababa
bababab
</pre>
- b
- <img src="...jpg">
- bbbbb
- <img src="...jpg">
- c
[/ul]
bye-bye
[ul]
- a
-- b
-- ababa
bbbb
--- bbbb
-- c
- fig.3
<table>
<tr><th>hello</th><th>world</th><tr>
<tr><td>100</td><td>2120</td><tr>
<tr><td>150</td><td>1505</td><tr>
</table>
[/ul]
the end
% ./conv-ulli.pl < conv-ulli-test.txt
hello
<ul>
<li>a
<pre>
abab
ababa
bababab
</pre></li>
<li>b
<ul>
<li><img src="...jpg">
<ul>
<li>bbbbb</li>
</ul>
</li>
<li><img src="...jpg"></li>
</ul>
</li>
<li>c</li>
</ul>
bye-bye
<ul>
<li>a
<ul>
<li>b</li>
<li>ababa
bbbb
<ul>
<li>bbbb</li>
</ul>
</li>
<li>c</li>
</ul>
</li>
<li>fig.3
<table>
<tr><th>hello</th><th>world</th><tr>
<tr><td>100</td><td>2120</td><tr>
<tr><td>150</td><td>1505</td><tr>
</table></li>
</ul>
the end
(Mac OS X) % ./conv-ulli.pl < conv-ulli-test.txt > conv-ulli-test-res.html % open conv-ulli-test-res.html![]()


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [ 次へ ]
たつをの ChangeLog