-
Notifications
You must be signed in to change notification settings - Fork 0
/
mknews.pl
42 lines (33 loc) · 969 Bytes
/
mknews.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use Plib;
$newsdir='news';
if ( not ( isdir($newsdir))){ dir("ERR: no dir $newsdir");}
@news = ();
@newsfiles = (tree($newsdir));
for $i (reverse(sort(@newsfiles))){
if ( not (isfile($i))){ next; };
$fbase=basename($i);
$fname=filename($fbase);
$htmlfile = ($fname . '.html');
$dir=dirname($i);
@dirs = splitdir($dir);
$topic = nth(0, @dirs );
$year = nth(1, @dirs );
@date = extract($fname, '^(\d\d)-(\d\d)_(.*)$');
$m = nth(0,@date);
$d = nth(1,@date);
$t = nth(2,@date);
$title = replace('-', ' ', $t);
$title = replace('_', ' ', $title);
@header = list(
("topic: " . $year . "/" . $m . "/" . $d),
(" **$title** "),
(" "),
(" "),
);
push(@news, @header);
push(@news, tostr(redir('<', $i)));
push(@news, '<hr>');
}
$nws = tostr(@news);
@htmlnews = sh("echo '$nws' | pandoc -s -f markdown -t html");
print(@htmlnews);