Blame Scripts/Functions/Html/Config/output_forHeadingsToc.awk

f3bce7
#!/usr/bin/gawk
f3bce7
#
f3bce7
# output_forHadingsToc.awk -- This file provides the output format
f3bce7
# required by html_updateHeadings.sh function, inside centos-art.sh
f3bce7
# script.
f3bce7
#
f3bce7
# Copyright (C) 2009-2010 Alain Reguera Delgado
f3bce7
# 
f3bce7
# This program is free software; you can redistribute it and/or modify
f3bce7
# it under the terms of the GNU General Public License as published by
f3bce7
# the Free Software Foundation; either version 2 of the License, or
f3bce7
# (at your option) any later version.
f3bce7
# 
f3bce7
# This program is distributed in the hope that it will be useful, but
f3bce7
# WITHOUT ANY WARRANTY; without even the implied warranty of
f3bce7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
f3bce7
# General Public License for more details.
f3bce7
#
f3bce7
# You should have received a copy of the GNU General Public 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) { 
f3bce7
        opentags  = "
  • "
f3bce7
        closetags = ""
f3bce7
    }
f3bce7
f3bce7
    if ($1 >  0 && $2 >  $3) {
f3bce7
        opentags  = "
  • "
f3bce7
        closetags = ""
f3bce7
    }
f3bce7
f3bce7
    if ($1 >  0 && $2 == $3) { 
f3bce7
        opentags  = "
  • "
  • f3bce7
            closetags = ""
    f3bce7
        }
    f3bce7
    f3bce7
        if ($1 >  0 && $2 <  $3) { 
    f3bce7
            opentags = ""
    f3bce7
            for (i = 1; i <= ($3 - $2); i++) {
    f3bce7
                opentags  = opentags ""
    f3bce7
                closetags = ""
    f3bce7
            }
    f3bce7
            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++) {
    f3bce7
                print ""
    f3bce7
            }
    f3bce7
        }
    f3bce7
        
    f3bce7
        if ($1 > 0 && $2 >= $3 && $3 == 1) {
    f3bce7
            print ""
    f3bce7
            print ""
    f3bce7
        }
    f3bce7
    f3bce7
        if ($1 > 0 && $2 < $3) {
    f3bce7
            for (i = 1; i <= $2; i++) {
    f3bce7
                print ""
    f3bce7
            }
    f3bce7
        }
    f3bce7
    f3bce7
        print ""
    f3bce7
    }