|
|
f8fb31 |
#!/bin/bash
|
|
|
f8fb31 |
#
|
|
|
1afa3c |
# texinfo_restoreCrossReferences.sh -- This function looks inside
|
|
|
e9dba2 |
# texinfo source files, from section level on, and restores any cross
|
|
|
e9dba2 |
# reference related to a documentation entry. This function is used in
|
|
|
e9dba2 |
# those cases where documentation entries are created/recreated to
|
|
|
e9dba2 |
# documentation structure. It is a verification that looks for
|
|
|
e9dba2 |
# matching documentation entries previously defined as removed by
|
|
|
1afa3c |
# texinfo_deleteCrossReferences function. The
|
|
|
1afa3c |
# texinfo_restoreCrossReferences function relays in the removed
|
|
|
1afa3c |
# message format produced by texinfo_deleteCrossReferences
|
|
|
deaa54 |
# function, in order to return them back into the link format.
|
|
|
f8fb31 |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f8fb31 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f8fb31 |
# General Public License for more details.
|
|
|
f8fb31 |
#
|
|
|
f8fb31 |
# You should have received a copy of the GNU General Public License
|
|
|
f8fb31 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
f8fb31 |
# ----------------------------------------------------------------------
|
|
|
f8fb31 |
# $Id$
|
|
|
f8fb31 |
# ----------------------------------------------------------------------
|
|
|
f8fb31 |
|
|
|
1afa3c |
function texinfo_restoreCrossReferences {
|
|
|
f8fb31 |
|
|
|
f8fb31 |
local -a PATTERN
|
|
|
f8fb31 |
local -a REPLACE
|
|
|
2924ec |
local LOCATION=''
|
|
|
f8fb31 |
|
|
|
2924ec |
# Define entry location. Verify first argument to make this
|
|
|
2924ec |
# function reusable. If no value is passed as first argument use
|
|
|
2924ec |
# entry global information value as default value instead.
|
|
|
2924ec |
if [[ "$1" != '' ]];then
|
|
|
2924ec |
LOCATION="$1"
|
|
|
2924ec |
else
|
|
|
2924ec |
LOCATION="$ENTRY"
|
|
|
2924ec |
fi
|
|
|
2924ec |
|
|
|
2924ec |
# Build the node string using entry location.
|
|
|
2924ec |
local NODE=$(echo "$LOCATION" \
|
|
|
edca1c |
| cut -d / -f8- \
|
|
|
f8fb31 |
| tr '/' ' ' \
|
|
|
1e404b |
| sed -r \
|
|
|
372a84 |
-e "s/(chapter-intro\.texi|\.texi)$//")
|
|
|
f8fb31 |
|
|
|
e9dba2 |
# Define regular expression patterns to match removed message
|
|
|
e9dba2 |
# format produced by message_removeCrossReferences function.
|
|
|
f8fb31 |
PATTERN[0]="--- @strong\{`gettext "Removed"`\}\((pxref|xref|ref):(${NODE})\) ---"
|
|
|
f8fb31 |
PATTERN[1]="^@comment --- `gettext "Removed"`\((\* ${NODE}:(.*)?:(.*)?)\) ---$"
|
|
|
f8fb31 |
|
|
|
e9dba2 |
# Define replacement string to turn removed message back to cross
|
|
|
e9dba2 |
# reference link.
|
|
|
f8fb31 |
REPLACE[0]='@\1{\2}'
|
|
|
f8fb31 |
REPLACE[1]='\1'
|
|
|
f8fb31 |
|
|
|
1e404b |
# Define list of entries to process.
|
|
|
a6a464 |
local ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} --pattern='.*\.texi')
|
|
|
1e404b |
|
|
|
1e404b |
# Update node-related cross references. The node-related cross
|
|
|
1e404b |
# reference definition, long ones specially, could require more
|
|
|
1e404b |
# than one line to be set. By default, GNU sed does not matches
|
|
|
1e404b |
# newline characters in the pattern space, so we need to make use
|
|
|
1e404b |
# of `label' feature and the `N' command in order to build a
|
|
|
1e404b |
# pattern space that includes the newline character in it. Here we
|
|
|
1e404b |
# use the `a' letter to name the label we use, followed by N
|
|
|
2924ec |
# command to add a newline to the pattern space, the s command to
|
|
|
2924ec |
# make the pattern replacement using the `g' flag to make it
|
|
|
2924ec |
# global and finaly the command `b' to branch label named `a'.
|
|
|
1e404b |
sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${ENTRIES}
|
|
|
1e404b |
|
|
|
1e404b |
# Update menu-related cross references. Menu-related cross
|
|
|
1e404b |
# references hardly appear in more than one line, so there is no
|
|
|
1e404b |
# need to complicate the replacement command.
|
|
|
1e404b |
sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${ENTRIES}
|
|
|
f8fb31 |
|
|
|
f8fb31 |
}
|