/* * $Id: doc.awk,v 1.4 2007/09/06 09:05:32 bacon Exp $ * * {License} */ global header, mode; global empty_line_count; global para_started; global list_count; global table_row_count; global table_row_line_count; global table_in_th; global tabs; function print_text (full) { local fra1, fra2, link, idx, t1, t2; gsub ("<", "\\<", full); gsub (">", "\\>", full); gsub (/\t/, tabs, 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%s%s", fra1, t2, t1, fra2); } while (match (full, /##\/[^\[\][:space:]]+\/##/) > 0) { fra1 = substr (full, 1, RSTART-1); link = substr (full, RSTART+3, RLENGTH-6); fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH); full = sprintf ("%s%s%s", fra1, link, fra2); } while (match (full, /##=[^#[:space:]]+=##/) > 0) { fra1 = substr (full, 1, RSTART-1); link = substr (full, RSTART+3, RLENGTH-6); fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH); full = sprintf ("%s%s%s", fra1, link, fra2); } while (match (full, /##-[^#[:space:]]+-##/) > 0) { fra1 = substr (full, 1, RSTART-1); link = substr (full, RSTART+3, RLENGTH-6); fra2 = substr (full, RSTART+RLENGTH, length(full)-RLENGTH); full = sprintf ("%s%s%s", fra1, link, fra2); } print full; } BEGIN { header = 1; mode = 0; empty_line_count = 0; para_started = 0; tabs = "\\ \\ \\ \\ \\ \\ \\ \\ "; #output=ARGV[1]; #gsub (/\.man/, ".html", output); #print "OUTPUT TO: " output; print ""; print ""; print ""; print ""; } header && /^\.[[:alpha:]]+[[:space:]]/ { if ($1 == ".title") { local i; printf ""; for (i = 2; i <= NF; i++) printf "%s ", $i; print ""; } else if ($1 == ".tabstop") { if (NF >= 2) { local i; for (i = 0; i < $2; i++) tabs = tabs . "\\ "; } } } header && !/^\.[[:alpha:]]+[[:space:]]/ { header = 0; print ""; print ""; } !header { local text; if (mode == 0) { if (/^$/) { # empty line if (para_started) { para_started = 0; print "

"; } empty_line_count++; } else { if (/^= [^=]+ =$/) { if (para_started) { print "

"; para_started = 0; } text=substr($0, 2, length($0)-2); print "

" . text . "

"; } else if (/^== [^=]+ ==$/) { if (para_started) { print "

"; para_started = 0; } text=substr($0, 3, length($0)-4); print "

" . text . "

"; } else if (/^=== [^=]+ ===$/) { if (para_started) { print "

"; para_started = 0; } text=substr($0, 4, length($0)-6); print "

" . text . "

"; } else if (/^==== [^=]+ ====$/) { if (para_started) { print "

"; para_started = 0; } text=substr($0, 5, length($0)-8); print "

" . text . "

"; } else if (/^\{\{\{$/) # {{{ { # {{{ if (para_started) { print "

"; para_started = 0; } print "
";
				mode = 1;
			}
			else if (/^\[\[\[$/) # [[[
			{
				if (para_started)
				{
					print "

"; para_started = 0; } print "