2007-02-04 13:00:37 +00:00
|
|
|
/*
|
2007-02-20 05:40:11 +00:00
|
|
|
* $Id: doc.awk,v 1.12 2007-02-20 05:40:11 bacon Exp $
|
2007-02-04 13:00:37 +00:00
|
|
|
*
|
|
|
|
* {License}
|
|
|
|
*/
|
|
|
|
|
2007-02-03 15:03:05 +00:00
|
|
|
global header, mode;
|
2007-02-04 05:03:01 +00:00
|
|
|
global empty_line_count;
|
|
|
|
global para_started;
|
2007-02-04 05:34:36 +00:00
|
|
|
global list_count;
|
2007-02-03 15:03:05 +00:00
|
|
|
|
2007-02-04 07:38:23 +00:00
|
|
|
func print_text (full)
|
|
|
|
{
|
|
|
|
local fra1, fra2, link, idx, t1, t2;
|
|
|
|
|
|
|
|
gsub ("<", "\\<", full);
|
|
|
|
gsub (">", "\\>", full);
|
|
|
|
|
|
|
|
while (match (full, /\{[^{},]+,[^{},]+\}/) > 0)
|
|
|
|
{
|
|
|
|
fra1 = substr (full, 1, RSTART-1);
|
|
|
|
link = substr (full, RSTART, RLENGTH);
|
|
|
|
fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH);
|
|
|
|
|
|
|
|
idx = index(link, ",");
|
|
|
|
t1 = substr (link, 2, idx-2);
|
|
|
|
t2 = substr (link, idx+1, length(link)-idx-1);
|
|
|
|
|
|
|
|
full = sprintf ("%s<a href='%s'>%s</a>%s", fra1, t2, t1, fra2);
|
|
|
|
}
|
|
|
|
|
|
|
|
print full;
|
|
|
|
}
|
|
|
|
|
2007-02-03 11:54:02 +00:00
|
|
|
BEGIN {
|
|
|
|
header = 1;
|
2007-02-03 15:03:05 +00:00
|
|
|
mode = 0;
|
2007-02-04 05:03:01 +00:00
|
|
|
empty_line_count = 0;
|
|
|
|
para_started = 0;
|
2007-02-04 04:40:33 +00:00
|
|
|
|
2007-02-05 14:35:10 +00:00
|
|
|
#output=ARGV[0];
|
|
|
|
#gsub (/\.man/, ".html", output);
|
2007-02-04 05:03:01 +00:00
|
|
|
#print "OUTPUT TO: " output;
|
2007-02-04 04:40:33 +00:00
|
|
|
|
|
|
|
print "</html>";
|
|
|
|
print "</head>";
|
2007-02-05 14:35:10 +00:00
|
|
|
print "<meta http-equiv='content-type' content='text/html; charset=UTF-8'>";
|
2007-02-04 05:34:36 +00:00
|
|
|
print "<link href='doc.css' rel='stylesheet' type='text/css' />";
|
2007-02-03 11:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
header && /^\.[[:alpha:]]+[[:space:]]/ {
|
|
|
|
if ($1 == ".title")
|
|
|
|
{
|
2007-02-04 14:24:10 +00:00
|
|
|
local i;
|
|
|
|
|
|
|
|
printf "<title>";
|
|
|
|
for (i = 2; i <= NF; i++) printf "%s ", $i;
|
|
|
|
print "</title>";
|
2007-02-03 11:54:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-04 04:40:33 +00:00
|
|
|
header && !/^\.[[:alpha:]]+[[:space:]]/ {
|
|
|
|
|
|
|
|
header = 0;
|
|
|
|
print "</head>";
|
|
|
|
print "<body>";
|
|
|
|
}
|
2007-02-03 11:54:02 +00:00
|
|
|
|
|
|
|
!header {
|
2007-02-03 15:03:05 +00:00
|
|
|
local text;
|
|
|
|
|
|
|
|
if (mode == 0)
|
2007-02-03 11:54:02 +00:00
|
|
|
{
|
2007-02-04 05:03:01 +00:00
|
|
|
if (/^$/)
|
2007-02-03 15:03:05 +00:00
|
|
|
{
|
2007-02-04 05:03:01 +00:00
|
|
|
# empty line
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
para_started = 0;
|
|
|
|
print "</p>";
|
|
|
|
}
|
|
|
|
empty_line_count++;
|
2007-02-03 15:03:05 +00:00
|
|
|
}
|
2007-02-04 04:40:33 +00:00
|
|
|
else
|
|
|
|
{
|
2007-02-04 05:03:01 +00:00
|
|
|
if (/^= [^=]+ =$/)
|
|
|
|
{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
|
|
|
text=substr($0, 2, length($0)-2);
|
|
|
|
print "<h1>" text "</h1>";
|
|
|
|
}
|
|
|
|
else if (/^== [^=]+ ==$/)
|
|
|
|
{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
|
|
|
text=substr($0, 3, length($0)-4);
|
|
|
|
print "<h2>" text "</h2>";
|
|
|
|
}
|
|
|
|
else if (/^=== [^=]+ ===$/)
|
|
|
|
{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
|
|
|
text=substr($0, 4, length($0)-6);
|
|
|
|
print "<h3>" text "</h3>";
|
|
|
|
}
|
|
|
|
else if (/^==== [^=]+ ====$/)
|
|
|
|
{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
|
|
|
text=substr($0, 5, length($0)-8);
|
2007-02-17 14:23:09 +00:00
|
|
|
print "<h4>" text "</h4>";
|
2007-02-04 05:03:01 +00:00
|
|
|
}
|
|
|
|
else if (/^\{\{\{$/)
|
|
|
|
{
|
|
|
|
# {{{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
2007-02-04 05:34:36 +00:00
|
|
|
print "<pre class='code'>";
|
2007-02-04 05:03:01 +00:00
|
|
|
mode = 1;
|
|
|
|
}
|
2007-02-04 05:34:36 +00:00
|
|
|
else if (/\[\[\[/)
|
|
|
|
{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
|
|
|
print "<ul>";
|
|
|
|
mode = 2;
|
|
|
|
list_count = 0;
|
|
|
|
}
|
2007-02-20 05:40:11 +00:00
|
|
|
else if (/\(\(\(/)
|
|
|
|
{
|
|
|
|
if (para_started)
|
|
|
|
{
|
|
|
|
print "</p>";
|
|
|
|
para_started = 0;
|
|
|
|
}
|
|
|
|
print "<ol>";
|
|
|
|
mode = 3;
|
|
|
|
list_count = 0;
|
|
|
|
}
|
2007-02-04 05:03:01 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!para_started > 0)
|
|
|
|
{
|
|
|
|
print "<p>";
|
|
|
|
para_started = 1;
|
|
|
|
}
|
|
|
|
|
2007-02-04 07:38:23 +00:00
|
|
|
/*
|
2007-02-04 05:03:01 +00:00
|
|
|
gsub ("<", "\\<");
|
|
|
|
gsub (">", "\\>");
|
|
|
|
print $0;
|
2007-02-04 07:38:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
print_text ($0);
|
2007-02-04 05:03:01 +00:00
|
|
|
print "<br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
empty_line_count = 0;
|
2007-02-04 04:40:33 +00:00
|
|
|
}
|
2007-02-03 11:54:02 +00:00
|
|
|
}
|
2007-02-03 15:03:05 +00:00
|
|
|
else if (mode == 1)
|
2007-02-03 11:54:02 +00:00
|
|
|
{
|
2007-02-03 15:03:05 +00:00
|
|
|
if (/^}}}$/)
|
|
|
|
{
|
2007-02-04 05:03:01 +00:00
|
|
|
# }}}
|
2007-02-03 15:03:05 +00:00
|
|
|
print "</pre>";
|
|
|
|
mode = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gsub ("<", "\\<");
|
|
|
|
gsub (">", "\\>");
|
|
|
|
print $0;
|
|
|
|
}
|
2007-02-03 11:54:02 +00:00
|
|
|
}
|
2007-02-04 05:34:36 +00:00
|
|
|
else if (mode == 2)
|
|
|
|
{
|
|
|
|
if (/^]]]$/)
|
|
|
|
{
|
2007-02-04 08:01:52 +00:00
|
|
|
# ]]]
|
2007-02-04 05:34:36 +00:00
|
|
|
print "</li>";
|
|
|
|
print "</ul>";
|
|
|
|
mode = 0;
|
|
|
|
}
|
|
|
|
else if (/^\* [^[:space:]]+/)
|
|
|
|
{
|
|
|
|
gsub ("<", "\\<");
|
|
|
|
gsub (">", "\\>");
|
|
|
|
if (list_count > 0) print "</li>";
|
|
|
|
print "<li>";
|
2007-02-04 07:38:23 +00:00
|
|
|
|
|
|
|
print_text (substr ($0, 3, length($0)-2));
|
2007-02-04 05:34:36 +00:00
|
|
|
list_count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-02-04 07:38:23 +00:00
|
|
|
print_text ($0);
|
2007-02-04 05:34:36 +00:00
|
|
|
}
|
|
|
|
}
|
2007-02-20 05:40:11 +00:00
|
|
|
else if (mode == 3)
|
|
|
|
{
|
|
|
|
if (/^\)\)\)$/)
|
|
|
|
{
|
|
|
|
# )))
|
|
|
|
print "</li>";
|
|
|
|
print "</ol>";
|
|
|
|
mode = 0;
|
|
|
|
}
|
|
|
|
else if (/^\* [^[:space:]]+/)
|
|
|
|
{
|
|
|
|
gsub ("<", "\\<");
|
|
|
|
gsub (">", "\\>");
|
|
|
|
if (list_count > 0) print "</li>";
|
|
|
|
print "<li>";
|
|
|
|
|
|
|
|
print_text (substr ($0, 3, length($0)-2));
|
|
|
|
list_count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print_text ($0);
|
|
|
|
}
|
|
|
|
}
|
2007-02-03 11:54:02 +00:00
|
|
|
}
|
2007-02-04 04:40:33 +00:00
|
|
|
|
|
|
|
END {
|
|
|
|
print "</body>";
|
|
|
|
print "</html>";
|
|
|
|
}
|