Hi folks, Since eLyXer was offered to be integrated with LyX it has gone a long way. The last version, 0.30, supports Python distutils -- this means that the eLyXer library can be easily installed in the user's Python libraries. This might help a lot for getting eLyXer integrated with LyX without having to actually insert its code there. Also, having to place the file elyxer.py in a specific directory within LyX is a suboptimal solution, as some users and integrators have complained: for every update you have to place elyxer.py into that folder again, or you lose the integration.
So everything that is needed is a bridge that can be used to call the local library. Attached is this file elyxerbridge.py, which should be added to directory $s/scripts/; it simply gathers command line parameters and calls elyxerconv with it. The detection method needs a little change, which is commented below. The enclosed code has the same license as LyX,and hereby I grant permission for its integration within the LyX code base and for use in the LyX project as it sees fit. I still dislike the way LyX deals with formats, and haven't found the time to play with Jürgen's new view options. But this new mechanism can be integrated with them, I hope, without further changes -- after all the lines I modified were not changed by Jürgen in this last round. (I will learn if any changes are needed as soon as I finish compiling latest from svn.) The enclosed patch should apply cleanly. Let me know what you think, Alex. --- start --- checkProg('an MS Word -> LaTeX converter', ['wvCleanLatex $$i $$o'], rc_entry = [ r'\converter word latex "%%" ""' ]) # # eLyXer: search as a library (elyxerconv) and then as an executable (elyxer.py, elyxer) elyxerfound = False print '+checking for "eLyXer Converter"... ', try: import elyxerconv # if the library elyxerconv can be found then elyxerbridge is used addToRC(r'''\converter lyx html "$$s/scripts/elyxerbridge.py --directory $$r $$i $$o" ""''') elyxerfound = True print ' yes' except ImportError: print ' no' # traditional lookup for the executable elyxer.py or just elyxer path, elyxer = checkProg('a LyX -> HTML converter', ['elyxer.py --directory $$r $$i $$o','elyxer --directory $$r $$i $$o'], rc_entry = [ r'\converter lyx html "%%" ""' ]) if elyxer.find('elyxer') >= 0: addToRC(r'''\copier html "python -tt $$s/scripts/ext_copy.py -e html,png,jpg,jpeg,css $$i $$o"''') elyxerfound = True if not elyxerfound: # now look for other HTML converters # On SuSE the scripts have a .sh suffix, and on debian they are in /usr/share/tex4ht/ --- end ---
Index: lib/scripts/elyxerbridge.py =================================================================== --- lib/scripts/elyxerbridge.py (revisión: 0) +++ lib/scripts/elyxerbridge.py (revisión: 0) @@ -0,0 +1,59 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# file elyxerbridge.py +# This file is part of LyX, the document processor. +# Licence details can be found in the file COPYING. + +# author Alex Fernandez (ely...@gmail.com) + +# Full author contact details are available in file CREDITS + +# Usage: +# elyxerbridge.py --directory <directory> <origin.lyx> <destination.html> + +# This script will convert the LyX file <origin.lyx> to <destination.html>, +# using eLyXer. If eLyXer is not present then an error will be recorded and +# shown to the user. + + +import sys +import os.path +try: + from elyxerconv import * +except: + print("Error: eLyXer not present") + exit() + +def readdir(filename, diroption): + "Read the current directory if needed" + if getattr(Options, diroption) != None: + return + setattr(Options, diroption, os.path.dirname(args[0])) + if getattr(Options, diroption) == '': + setattr(Options, diroption, '.') + +def convertdoc(args): + "Read a whole book, write it" + if len(args) != 2: + usage() + readdir(args[0], 'directory') + readdir(args[0], 'destdirectory') + filein = args[0] + del args[0] + fileout = args[0] + del args[0] + converter = eLyXerConverter(filein, fileout) + converter.convert() + +def usage(): + "Show usage message" + Trace.message('eLyXer Bridge error: must specify both origin and destination files.') + Trace.message(' usage: elyxerbridge --directory directory input.lyx output.html') + exit() + +args = sys.argv +del args[0] +Options().parseoptions(args) +convertdoc(args) + Cambios de propiedades en lib/scripts/elyxerbridge.py ___________________________________________________________________ Añadido: svn:executable + * Index: lib/configure.py =================================================================== --- lib/configure.py (revisión: 31391) +++ lib/configure.py (copia de trabajo) @@ -605,11 +605,23 @@ checkProg('an MS Word -> LaTeX converter', ['wvCleanLatex $$i $$o'], rc_entry = [ r'\converter word latex "%%" ""' ]) # - path, elyxer = checkProg('a LyX -> HTML converter', ['elyxer.py', 'elyxer'], - rc_entry = [ r'\converter lyx html "python -tt $$s/scripts/elyxer.py --directory $$r $$i $$o" ""' ]) - if elyxer.find('elyxer') >= 0: - addToRC(r'''\copier html "python -tt $$s/scripts/ext_copy.py -e html,png,jpg,jpeg,css $$i $$o"''') - else: + # eLyXer: search as a library (elyxerconv) and then as an executable (elyxer.py, elyxer) + elyxerfound = False + print '+checking for "eLyXer Converter"... ', + try: + import elyxerconv + addToRC(r'''\converter lyx html "$$s/scripts/elyxerbridge.py --directory $$r $$i $$o" ""''') + elyxerfound = True + print ' yes' + except ImportError: + print ' no' + path, elyxer = checkProg('a LyX -> HTML converter', ['elyxer.py --directory $$r $$i $$o','elyxer --directory $$r $$i $$o'], + rc_entry = [ r'\converter lyx html "%%" ""' ]) + if elyxer.find('elyxer') >= 0: + addToRC(r'''\copier html "python -tt $$s/scripts/ext_copy.py -e html,png,jpg,jpeg,css $$i $$o"''') + elyxerfound = True + + if not elyxerfound: # On SuSE the scripts have a .sh suffix, and on debian they are in /usr/share/tex4ht/ path, htmlconv = checkProg('a LaTeX -> HTML converter', ['htlatex $$i', 'htlatex.sh $$i', \ '/usr/share/tex4ht/htlatex $$i', 'tth -t -e2 -L$$b < $$i > $$o', \