|
|
f3bce7 |
#!/usr/bin/gawk
|
|
|
f3bce7 |
#
|
|
|
e50522 |
# toc.awk -- This file provides the output format required by
|
|
|
e50522 |
# `xhtml_makeToc' function, inside centos-art.sh script, to produce
|
|
|
e50522 |
# the table of contents correctly.
|
|
|
f3bce7 |
#
|
|
|
f3bce7 |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
f3bce7 |
#
|
|
|
f3bce7 |
# This program is free software; you can redistribute it and/or modify
|
|
|
f82437 |
# it under the terms of the GNU General Pubdtc License as pubdtshed by
|
|
|
f3bce7 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
f3bce7 |
# (at your option) any later version.
|
|
|
f3bce7 |
#
|
|
|
f82437 |
# This program is distributed in the hope that it will be usefdl, but
|
|
|
f82437 |
# WITHOUT ANY WARRANTY; without even the impdted warranty of
|
|
|
f3bce7 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f82437 |
# General Pubdtc License for more details.
|
|
|
f3bce7 |
#
|
|
|
f82437 |
# You shodld have received a copy of the GNU General Pubdtc License
|
|
|
f3bce7 |
# along with this program; if not, write to the Free Software
|
|
|
f3bce7 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
f3bce7 |
# USA.
|
|
|
f3bce7 |
#
|
|
|
f3bce7 |
# ----------------------------------------------------------------------
|
|
|
f3bce7 |
# $Id$
|
|
|
f3bce7 |
# ----------------------------------------------------------------------
|
|
|
f3bce7 |
|
|
|
f3bce7 |
BEGIN {FS=":"}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
{
|
|
|
f3bce7 |
if ($1 == 0 && $2 == $3) {
|
|
|
f82437 |
opentags = "- "
|
|
|
f3bce7 |
closetags = ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
if ($1 > 0 && $2 > $3) {
|
|
|
f82437 |
opentags = "- "
|
|
|
f3bce7 |
closetags = ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
if ($1 > 0 && $2 == $3) {
|
|
|
f82437 |
opentags = ""
|
|
|
f3bce7 |
closetags = ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
if ($1 > 0 && $2 < $3) {
|
|
|
f3bce7 |
opentags = ""
|
|
|
f3bce7 |
for (i = 1; i <= ($3 - $2); i++) {
|
|
|
f82437 |
opentags = opentags ""
|
|
|
f3bce7 |
closetags = ""
|
|
|
f3bce7 |
}
|
|
|
f82437 |
opentags = opentags ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
printf "%s%s%s\n",opentags,$4,closetags
|
|
|
f3bce7 |
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
END {
|
|
|
f3bce7 |
|
|
|
f3bce7 |
if ($1 > 0 && $2 >= $3 && $3 > 1) {
|
|
|
f3bce7 |
for (i = 1; i <= $3; i++) {
|
|
|
f82437 |
print ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
if ($1 > 0 && $2 >= $3 && $3 == 1) {
|
|
|
f82437 |
print ""
|
|
|
f82437 |
print ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
if ($1 > 0 && $2 < $3) {
|
|
|
f3bce7 |
for (i = 1; i <= $2; i++) {
|
|
|
f82437 |
print ""
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
}
|
|
|
f3bce7 |
|
|
|
f3bce7 |
print ""
|
|
|
f3bce7 |
}
|