|
|
8d1098 |
#!/bin/bash
|
|
|
8d1098 |
#
|
|
|
5b24c1 |
# svg_convertToText.sh -- This function takes the XHTML file produced
|
|
|
5b24c1 |
# by docbook_convertToXhtml and produces one plain-text file (i.e.,
|
|
|
5b24c1 |
# without markup inside).
|
|
|
8d1098 |
#
|
|
|
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
|
|
|
8d1098 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8d1098 |
# General Public License for more details.
|
|
|
8d1098 |
#
|
|
|
8d1098 |
# You should have received a copy of the GNU General Public License
|
|
|
8d1098 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
8d1098 |
# ----------------------------------------------------------------------
|
|
|
8d1098 |
# $Id$
|
|
|
8d1098 |
# ----------------------------------------------------------------------
|
|
|
8d1098 |
|
|
|
5b24c1 |
function xhtml_convertToText {
|
|
|
8d1098 |
|
|
|
5b24c1 |
# Verify existence of HTML file. If `.xhtml' file doesn't exist
|
|
|
5b24c1 |
# don't create text file. The `.xhtml' file is required in order
|
|
|
5b24c1 |
# to create the `.txt' file.
|
|
|
5b24c1 |
if [[ ! -f ${FILE}.xhtml ]];then
|
|
|
5b24c1 |
return
|
|
|
5b24c1 |
fi
|
|
|
8d1098 |
|
|
|
8d1098 |
local COMMAND=''
|
|
|
8d1098 |
local OPTIONS=''
|
|
|
8d1098 |
|
|
|
8d1098 |
# Define the command path to text-based web browser and options
|
|
|
8d1098 |
# used to produce plain-text files. Most of these programs have a
|
|
|
8d1098 |
# dump option that print formatted plain-text versions of given
|
|
|
8d1098 |
# HTML file to stdout.
|
|
|
8d1098 |
if [[ -x '/usr/bin/lynx' ]];then
|
|
|
8d1098 |
COMMAND='/usr/bin/lynx'
|
|
|
8d1098 |
OPTIONS='-force_html -nolist -width 70 -dump'
|
|
|
8d1098 |
elif [[ -x '/usr/bin/elinks' ]];then
|
|
|
8d1098 |
COMMAND='/usr/bin/elinks'
|
|
|
8d1098 |
OPTIONS='-force_html -no-numbering -no-references -width 70 -dump'
|
|
|
8d1098 |
elif [[ -x '/usr/bin/w3m' ]];then
|
|
|
8d1098 |
COMMAND='/usr/bin/w3m'
|
|
|
8d1098 |
OPTIONS='-dump'
|
|
|
8d1098 |
fi
|
|
|
8d1098 |
|
|
|
8d1098 |
if [[ $COMMAND != '' ]];then
|
|
|
8d1098 |
|
|
|
8d1098 |
# Print action message.
|
|
|
8d1098 |
if [[ -f ${FILE}.txt ]];then
|
|
|
0ff158 |
cli_printMessage "${FILE}.txt" --as-updating-line
|
|
|
8d1098 |
else
|
|
|
0ff158 |
cli_printMessage "${FILE}.txt" --as-creating-line
|
|
|
8d1098 |
fi
|
|
|
8d1098 |
|
|
|
8d1098 |
# Convert from HTML to plain-text without markup.
|
|
|
8d1098 |
${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt
|
|
|
8d1098 |
|
|
|
8d1098 |
else
|
|
|
5b24c1 |
cli_printMessage "`gettext "No way to convert from XHTML to plain-text found."`" --as-error-line
|
|
|
8d1098 |
fi
|
|
|
8d1098 |
|
|
|
8d1098 |
}
|