adapt rcllyx to newer lyx which apparently always export utf-8

This commit is contained in:
Jean-Francois Dockes 2010-09-30 17:49:38 +02:00
parent 7b803170c2
commit 910f995530
2 changed files with 72 additions and 57 deletions

View File

@ -139,29 +139,43 @@ textfile=$workdir/`basename "$binfile" .lyx`.txt
#echo binfile: $binfile;echo lyxfile: $lyxfile ; ls -l $lyxfile; echo textfile: $textfile #echo binfile: $binfile;echo lyxfile: $lyxfile ; ls -l $lyxfile; echo textfile: $textfile
# Run lyx --export # Run lyx --export
lyx --export text "$lyxfile" lyx --export text "$lyxfile" || senderror "lyx --export not working"
# Charset and language # Need the lyx version. After some point -export prints utf-8,
formatline=`egrep '^\\\lyxformat ' "$lyxfile"` # whatever the input version
if test -n "$formatline" ; then LYXOUTPUTUTF=No
vline=`lyx --version 2>&1 | head -1 | tr '.' ' '`
set $vline
maj=`expr $2 '*' 10000` || senderror "Bad lyx version string $vline"
med=`expr $3 '*' 100` || senderror "Bad lyx version string $vline"
min=`expr $4 '*' 1` || senderror "Bad lyx version string $vline"
version=`expr $maj + $med + $min` || senderror "Bad lyx version string $vline"
if test $version -ge 10607 ; then
LYXOUTPUTUTF=Yes
fi
if test X$LYXOUTPUTUTF = XNo ; then
echo "OLD VERSION"
# Charset and language
formatline=`egrep '^\\\lyxformat ' "$lyxfile"`
if test -n "$formatline" ; then
set $formatline set $formatline
format=$2 format=$2
fi fi
charsetline=`egrep '^\\\inputencoding ' "$lyxfile"` charsetline=`egrep '^\\\inputencoding ' "$lyxfile"`
if test -n "$charsetline" ; then if test -n "$charsetline" ; then
set $charsetline set $charsetline
charset=$2 charset=$2
fi fi
langline=`egrep '^\\\language ' "$lyxfile"` langline=`egrep '^\\\language ' "$lyxfile"`
if test -n "$langline" ; then if test -n "$langline" ; then
set $langline set $langline
lang=$2 lang=$2
fi fi
#echo format: [$format] charset: [$charset] lang [$lang] #echo format: [$format] charset: [$charset] lang [$lang]
if test "$format" -ge 249 ; then if test "$format" -ge 249 ; then
charset=utf-8 charset=utf-8
else else
# try to guess the charset from the language: this is in no way guaranteed # try to guess the charset from the language: this is in no way guaranteed
# to work, the logic has built-in inconsistencies even beyond the numerous # to work, the logic has built-in inconsistencies even beyond the numerous
# external ones (what if the ukrainian writer prefers koi8-r ?). This is a # external ones (what if the ukrainian writer prefers koi8-r ?). This is a
@ -195,6 +209,8 @@ else
charset=iso-8859-1;; charset=iso-8859-1;;
esac esac
fi fi
fi
# End Old lyx needing output tweaking
fi fi
if test -n "$charset" ; then if test -n "$charset" ; then

View File

@ -5,12 +5,11 @@ topdir=`dirname $0`/..
initvariables $0 initvariables $0
recollq 'Bienvenue Dans Univers De Lyx' 2> $mystderr | (
egrep -v '^Recoll query: ' > $mystdout recollq 'Bienvenue Dans Univers De Lyx'
recollq 'Welcome To Lyx' 2>> $mystderr | recollq 'Welcome To Lyx'
egrep -v '^Recoll query: ' >> $mystdout recollq 'Udvozli Ont A LyX'
recollq 'Udvozli Ont A LyX' 2>> $mystderr | ) 2> $mystderr | egrep -v '^Recoll query: ' > $mystdout
egrep -v '^Recoll query: ' >> $mystdout
diff -w ${myname}.txt $mystdout > $mydiffs 2>&1 diff -w ${myname}.txt $mystdout > $mydiffs 2>&1