From ab8744e5749fde5eeb7577ed6532e36f04b186bf Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Mar 08 2011 16:48:01 +0000 Subject: Rename identity_renderHtmlPlaintext to identity_convertHtml2Text. --- diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_convertHtml2Text.sh b/Scripts/Bash/Cli/Functions/Identity/identity_convertHtml2Text.sh new file mode 100755 index 0000000..fc5c9cb --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Identity/identity_convertHtml2Text.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# identity_convertHtml2Text.sh -- This function takes one HTML file +# and produces one plain-text file (i.e., without markup inside). +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function identity_convertHtml2Text { + + # Verify existence of HTML file. + cli_checkFiles ${FILE}.xhtml 'f' + + local COMMAND='' + local OPTIONS='' + + # Define the command path to text-based web browser and options + # used to produce plain-text files. Most of these programs have a + # dump option that print formatted plain-text versions of given + # HTML file to stdout. + if [[ -x '/usr/bin/lynx' ]];then + COMMAND='/usr/bin/lynx' + OPTIONS='-force_html -nolist -width 70 -dump' + elif [[ -x '/usr/bin/elinks' ]];then + COMMAND='/usr/bin/elinks' + OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' + elif [[ -x '/usr/bin/w3m' ]];then + COMMAND='/usr/bin/w3m' + OPTIONS='-dump' + fi + + if [[ $COMMAND != '' ]];then + + # Print action message. + if [[ -f ${FILE}.txt ]];then + cli_printMessage "${FILE}.txt" 'AsUpdatingLine' + else + cli_printMessage "${FILE}.txt" 'AsCreatingLine' + fi + + # Convert from HTML to plain-text without markup. + ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt + + else + cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh index 99580a5..b490d22 100755 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh +++ b/Scripts/Bash/Cli/Functions/Identity/identity_renderDocbook.sh @@ -31,6 +31,6 @@ function identity_renderDocbook { identity_renderDocbookXhtml # Produce plaintext output from html outout. - identity_renderHtmlPlaintext + identity_convertHtml2Text } diff --git a/Scripts/Bash/Cli/Functions/Identity/identity_renderHtmlPlaintext.sh b/Scripts/Bash/Cli/Functions/Identity/identity_renderHtmlPlaintext.sh deleted file mode 100755 index c931d81..0000000 --- a/Scripts/Bash/Cli/Functions/Identity/identity_renderHtmlPlaintext.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# identity_renderHtmlPlaintext.sh -- This function takes one HTML file -# and produces one plain-text file (i.e., without markup inside). -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function identity_renderHtmlPlaintext { - - # Verify existence of HTML file. - cli_checkFiles ${FILE}.xhtml 'f' - - local COMMAND='' - local OPTIONS='' - - # Define the command path to text-based web browser and options - # used to produce plain-text files. Most of these programs have a - # dump option that print formatted plain-text versions of given - # HTML file to stdout. - if [[ -x '/usr/bin/lynx' ]];then - COMMAND='/usr/bin/lynx' - OPTIONS='-force_html -nolist -width 70 -dump' - elif [[ -x '/usr/bin/elinks' ]];then - COMMAND='/usr/bin/elinks' - OPTIONS='-force_html -no-numbering -no-references -width 70 -dump' - elif [[ -x '/usr/bin/w3m' ]];then - COMMAND='/usr/bin/w3m' - OPTIONS='-dump' - fi - - if [[ $COMMAND != '' ]];then - - # Print action message. - if [[ -f ${FILE}.txt ]];then - cli_printMessage "${FILE}.txt" 'AsUpdatingLine' - else - cli_printMessage "${FILE}.txt" 'AsCreatingLine' - fi - - # Convert from HTML to plain-text without markup. - ${COMMAND} ${OPTIONS} ${FILE}.xhtml > ${FILE}.txt - - else - cli_printMessage "`gettext "No way to convert from HTML to plain-text found."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -}