|
|
d286ed |
#!/bin/bash
|
|
|
d286ed |
#
|
|
|
d286ed |
# texinfo_getEntryTitle.sh -- This function standardizes the way entry
|
|
|
d286ed |
# titles for chapters and sections are printed out.
|
|
|
d286ed |
#
|
|
|
d286ed |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
d286ed |
#
|
|
|
d286ed |
# This program is free software; you can redistribute it and/or modify
|
|
|
d286ed |
# it under the terms of the GNU General Public License as published by
|
|
|
d286ed |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
d286ed |
# your option) any later version.
|
|
|
d286ed |
#
|
|
|
d286ed |
# This program is distributed in the hope that it will be useful, but
|
|
|
d286ed |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d286ed |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d286ed |
# General Public License for more details.
|
|
|
d286ed |
#
|
|
|
d286ed |
# You should have received a copy of the GNU General Public License
|
|
|
d286ed |
# along with this program; if not, write to the Free Software
|
|
|
d286ed |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
d286ed |
#
|
|
|
d286ed |
# ----------------------------------------------------------------------
|
|
|
d286ed |
# $Id$
|
|
|
d286ed |
# ----------------------------------------------------------------------
|
|
|
d286ed |
|
|
|
d286ed |
function texinfo_getEntryTitle {
|
|
|
d286ed |
|
|
|
d286ed |
# Initialize phrase we want to transform based on style provided.
|
|
|
d286ed |
local PHRASE="$1"
|
|
|
d286ed |
|
|
|
d286ed |
# Verify style provided through `--style' option and transform
|
|
|
d286ed |
# the phrase value in accordance with it.
|
|
|
d286ed |
if [[ $FLAG_STYLE == 'cap-first-only' ]];then
|
|
|
d286ed |
|
|
|
d286ed |
# In the entire phrase provided, capitalize the first word
|
|
|
d286ed |
# only.
|
|
|
d286ed |
PHRASE=$(echo "${PHRASE}" | tr '[:upper:]' '[:lower:]' \
|
|
|
d286ed |
| sed -r 's!^([[:alpha:]])!\u\1!')
|
|
|
d286ed |
|
|
|
d286ed |
elif [[ $FLAG_STYLE == 'directory' ]];then
|
|
|
d286ed |
|
|
|
d286ed |
# In the entire phrase provided, concatenate all words with
|
|
|
d286ed |
# slash (/) character and remark the fact it is a directory.
|
|
|
d286ed |
PHRASE=$(echo "${PHRASE}" | sed -r \
|
|
|
a184d3 |
-e 's/(Trunk|Branches|Tags)/\l\1/' \
|
|
|
a184d3 |
-e 's/ /\//g' \
|
|
|
a184d3 |
-e 's/\/([[:alpha:]])/\/\u\1/g')
|
|
|
d286ed |
|
|
|
588b7d |
PHRASE="@file{$PHRASE}"
|
|
|
d286ed |
|
|
|
d286ed |
else
|
|
|
d286ed |
|
|
|
d286ed |
# In the entire phrase provided, capitalize all words.
|
|
|
d286ed |
PHRASE=$(echo "${PHRASE}" | tr '[:upper:]' '[:lower:]' \
|
|
|
d286ed |
| sed -r 's!\<([[:alpha:]]+)\>!\u\1!g')
|
|
|
d286ed |
|
|
|
d286ed |
fi
|
|
|
d286ed |
|
|
|
d286ed |
# Output transformed phrase.
|
|
|
d286ed |
echo "$PHRASE"
|
|
|
d286ed |
|
|
|
d286ed |
}
|