All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Till Kamppeter <till.kamppeter@gmail.com>
Cc: printing-architecture@lists.linux-foundation.org
Subject: Re: [Printing-architecture] [PATCH] braille: Checking for tool presence
Date: Thu, 21 Jan 2016 00:28:07 +0100	[thread overview]
Message-ID: <20160120232807.GA465@var.home> (raw)
In-Reply-To: <569EBD80.3040504@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

The attached patch makes cups-filter able to use lou_translate from
liblouis-bin (and warn about that) when file2brl from liblouisutdml-bin
is not available.

Samuel

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 4419 bytes --]

=== modified file 'filter/braille/filters/texttobrf.in'
--- filter/braille/filters/texttobrf.in	2016-01-19 22:48:12 +0000
+++ filter/braille/filters/texttobrf.in	2016-01-20 23:25:50 +0000
@@ -54,58 +54,13 @@ fi
 
 echo "DEBUG: Input content type: $CONTENT_TYPE" >&2
 
-#  Selected braille table
-if [ -n "$LIBLOUIS_TABLES" ]
-then
-  checkTool file2brl liblouis "translating braille"
+# FIXME CONTENT_TYPE contains original document, not document passed as parameter ?!!
 
-  #  Tool to be used for the conversion
-  # FIXME CONTENT_TYPE contains original document, not document passed as parameter ?!!
-  case $CONTENT_TYPE in
-    text/plain)
-      LIBLOUIS_TOOL="file2brl"
-      CONVERT=""
-      ;;
-    text/html)
-      LIBLOUIS_TOOL="file2brl -t"
-      CONVERT=""
-      ;;
-    text/xml|application/xml|application/xhtml+xml)
-      LIBLOUIS_TOOL="file2brl"
-      CONVERT=""
-      ;;
-    application/msword)
-      LIBLOUIS_TOOL="file2brl"
-      CONVERT="antiword -x db /dev/stdin"
-      checkTool antiword antiword "translating MS-Word doc files"
-      ;;
-    application/vnd.openxmlformats-officedocument.wordprocessingml.document)
-      LIBLOUIS_TOOL="file2brl"
-      CONVERT="docx2txt"
-      checkTool docx2txt docx2txt "translating MS-Word docx files"
-      ;;
-    text/rtf|application/rtf)
-      LIBLOUIS_TOOL="file2brl"
-      CONVERT="rtf2xml /dev/stdin"
-      checkTool rtf2xml rtf2xml "translating RTF files"
-      ;;
-    application/pdf)
-      LIBLOUIS_TOOL="file2brl -p"
-      CONVERT="pdftotext -raw /dev/stdin /dev/stdout"
-      checkTool pdftotext poppler "translating PDF files"
-      ;;
-    *)
-      echo "ERROR: unsupported content type $CONTENT_TYPE" >&2
-      exit 1
-      ;;
-  esac
-  RENDER_CALL="$LIBLOUIS_TOOL -CliteraryTextTable=$LIBLOUIS_TABLES,braille-patterns.cti $LIBLOUIS_CONFIG"
-else
+setupTextRendering() {
   # Default rendering without translation: just reformat paragraphs
   RENDER_CALL="fmt -$TEXTWIDTH"
 
   #  Tool to be used for the conversion
-  # FIXME CONTENT_TYPE contains original document, not document passed as parameter ?!!
   case $CONTENT_TYPE in
     text/plain)
       CONVERT=""
@@ -136,6 +91,66 @@ else
       exit 1
       ;;
   esac
+}
+
+#  Selected braille table
+if [ -n "$LIBLOUIS_TABLES" ]
+then
+  if type file2brl
+  then
+    # Good, we can use liblouisutdml
+    case $CONTENT_TYPE in
+      text/plain)
+	LIBLOUIS_TOOL="file2brl"
+	CONVERT=""
+	;;
+      text/html)
+	LIBLOUIS_TOOL="file2brl -t"
+	CONVERT=""
+	;;
+      text/xml|application/xml|application/xhtml+xml)
+	LIBLOUIS_TOOL="file2brl"
+	CONVERT=""
+	;;
+      application/msword)
+	LIBLOUIS_TOOL="file2brl"
+	CONVERT="antiword -x db /dev/stdin"
+	checkTool antiword antiword "translating MS-Word doc files"
+	;;
+      application/vnd.openxmlformats-officedocument.wordprocessingml.document)
+	LIBLOUIS_TOOL="file2brl"
+	CONVERT="docx2txt"
+	checkTool docx2txt docx2txt "translating MS-Word docx files"
+	;;
+      text/rtf|application/rtf)
+	LIBLOUIS_TOOL="file2brl"
+	CONVERT="rtf2xml /dev/stdin"
+	checkTool rtf2xml rtf2xml "translating RTF files"
+	;;
+      application/pdf)
+	LIBLOUIS_TOOL="file2brl -p"
+	CONVERT="pdftotext -raw /dev/stdin /dev/stdout"
+	checkTool pdftotext poppler "translating PDF files"
+	;;
+      *)
+	echo "ERROR: unsupported content type $CONTENT_TYPE" >&2
+	exit 1
+	;;
+    esac
+    RENDER_CALL="$LIBLOUIS_TOOL -CliteraryTextTable=$LIBLOUIS_TABLES,braille-patterns.cti $LIBLOUIS_CONFIG"
+  elif type lou_translate
+  then
+    # Only liblouis, but better than nothing
+    setupTextRendering
+    printf "WARN: The liblouisutdml package is required for translating braille better\n" >&2
+    TRANSLATE="lou_translate $LIBLOUIS_TABLES,braille-patterns.cti"
+  else
+    printf "ERROR: The liblouisutdml package is required for translating braille\n" >&2
+    exit 1
+  fi
+else
+  # No translation, only text rendering
+  setupTextRendering
 fi
 
 # Now proceeed
@@ -147,9 +162,13 @@ if [ -z "$CONVERT" ]
 then
   printf "DEBUG: Calling $RENDER_CALL on '%s'\n" "$FILE" >&2
    < "$FILE" $RENDER_CALL
-else
+elif [ -z "$TRANSLATE" ]
+then
   printf "DEBUG: Calling $CONVERT | $RENDER_CALL on '%s'\n" "$FILE" >&2
   < "$FILE" $CONVERT | $RENDER_CALL
+else
+  printf "DEBUG: Calling $CONVERT | $RENDER_CALL | $TRANSLATE on '%s'\n" "$FILE" >&2
+  < "$FILE" $CONVERT | $RENDER_CALL | $TRANSLATE
 fi
 
 echo "INFO: Ready" >&2


  reply	other threads:[~2016-01-20 23:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-19 22:09 [Printing-architecture] [PATCH] braille: Checking for tool presence Samuel Thibault
2016-01-19 22:49 ` Till Kamppeter
2016-01-20 23:28   ` Samuel Thibault [this message]
2016-01-21  1:17     ` Till Kamppeter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160120232807.GA465@var.home \
    --to=samuel.thibault@ens-lyon.org \
    --cc=printing-architecture@lists.linux-foundation.org \
    --cc=till.kamppeter@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.