|
|
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 |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
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
|
|
|
f8fb31 |
|
|
|
7fde3b |
# Define documentation entry.
|
|
|
7fde3b |
local MANUAL_ENTRY="$1"
|
|
|
7fde3b |
|
|
|
7fde3b |
# Verify documentation entry. If documentation entry is empty,
|
|
|
7fde3b |
# stop script execution with an error message.
|
|
|
7fde3b |
if [[ $MANUAL_ENTRY == '' ]];then
|
|
|
7fde3b |
cli_printMessage "`gettext "The first positional parameter cannot be empty."`" --as-error-line
|
|
|
2924ec |
fi
|
|
|
2924ec |
|
|
|
2924ec |
# Build the node string using entry location.
|
|
|
7fde3b |
local NODE=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY")
|
|
|
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.
|
|
|
7fde3b |
local MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} --pattern=".*\.${FLAG_BACKEND}")
|
|
|
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'.
|
|
|
7fde3b |
#
|
|
|
7fde3b |
# Inside the pattern space, the `\<' and `\>' are used to restrict
|
|
|
7fde3b |
# the match pattern to a word boundary. The word boundary
|
|
|
7fde3b |
# restriction applied here is required to avoid undesired
|
|
|
7fde3b |
# replacements when we replace singular words with their plurals.
|
|
|
7fde3b |
# For example, if we need to change the word `Manual' to its
|
|
|
7fde3b |
# plular (i.e., `Manuals'), and no boundary restriction is used in
|
|
|
7fde3b |
# the pattern space to do that, we might end up having words like
|
|
|
7fde3b |
# `Manualsssss'. This is because this sed command might be applied
|
|
|
7fde3b |
# to the same file many times; and each time it is applied a new
|
|
|
7fde3b |
# `Manuals' replaces the previous `Manuals' replacement to form
|
|
|
7fde3b |
# `Manualss', `Manualsss', and so on for each interaction.
|
|
|
7fde3b |
sed -r -i ":a;N;s!\<${PATTERN[0]}\>!${REPLACE[0]}!g;ba" ${MANUAL_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.
|
|
|
7fde3b |
sed -r -i "s!\<${PATTERN[1]}\>!${REPLACE[1]}!" ${MANUAL_ENTRIES}
|
|
|
f8fb31 |
|
|
|
f8fb31 |
}
|