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