| version 1.15, 2002/09/04 21:24:55 |
version 1.16, 2002/09/06 00:38:04 |
|
|
| |
|
| # $Id$ |
# $Id$ |
| |
|
| |
BEGIN { |
| |
read_id(IDfile); |
| |
} |
| |
|
| |
function read_id(file) |
| |
{ # {{{ |
| |
while (getline tag < file) { |
| |
n = split(tag, a, "\t+"); |
| |
IDs[a[1]] = tag; |
| |
} |
| |
} # }}} |
| |
|
| |
function get_field(str, i) |
| |
{ # {{{ |
| |
n = split(IDs[str], a, "\t+"); |
| |
return a[i]; |
| |
} # }}} |
| |
|
| |
function remove_tag(s, reg) |
| |
{ # {{{ |
| |
sub(/\t+/, " ", s); |
| |
reg1 = sprintf("^.*<%s[^>]*> *", reg); |
| |
reg2 = sprintf(" *</%s>.*$", reg); |
| |
if (!sub(reg1, "", s)) { s = ""; } |
| |
if (!sub(reg2, "", s)) { s = ""; } |
| |
|
| |
return s; |
| |
} # }}} |
| |
|
| |
function complete_xref(str, reg) |
| |
{ # {{{ |
| |
reg1 = sprintf("<%s[^>]*>", reg); |
| |
|
| |
while (str !~ reg1) { |
| |
# printf "BEFORE = '%s'\n", str; |
| |
getline; |
| |
str = sprintf("%s %s", str, $0); |
| |
# printf "AFTER = '%s'\n", str; |
| |
} |
| |
|
| |
return str; |
| |
|
| |
} # }}} |
| |
|
| |
function handle_xref(str) |
| |
{ # {{{ |
| |
str = complete_xref(str, "xref"); |
| |
# now we substitute tag <xref ...> with apropriate ID |
| |
id = find_id(str); |
| |
sub(/<xref[^>]*>/, sprintf("%s", get_field(id, 5)), str); |
| |
print str; |
| |
} # }}} |
| |
|
| |
# return "endterm" value of <xref ...> tag |
| |
function find_id(str) |
| |
{ # {{{ |
| |
sub(/^.*<xref.*endterm=['"]/, "", str); |
| |
sub(/['"].*$/, "", str); |
| |
return str; |
| |
} # }}} |
| |
|
| function remove_lines(str) |
function remove_lines(str) |
| { # {{{ |
{ # {{{ |
| while (getline) { |
while (getline) { |
| Line 81 function handle_table(str) |
|
| Line 142 function handle_table(str) |
|
| handle_man($0); |
handle_man($0); |
| continue; |
continue; |
| } |
} |
| |
if ($0 ~ /<xref/) { |
| |
handle_xref($0); |
| |
continue; |
| |
} |
| |
|
| print; |
print; |
| } |
} |
| Line 97 function handle_table(str) |
|
| Line 162 function handle_table(str) |
|
| next; |
next; |
| } |
} |
| |
|
| |
/<xref/ { |
| |
handle_xref($0); |
| |
next; |
| |
} |
| |
|
| # remove "<sect1 .*</title>" -- MUST be on begin of the line! |
# remove "<sect1 .*</title>" -- MUST be on begin of the line! |
| /<sect1/ { |
/<sect1/ { |
| remove_lines("^.*<\/title>"); |
remove_lines("^.*<\/title>"); |