Blame tcar-scripts-tuneup/Modules/Xhtml/Configs/toc.awk

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