Jean-Marc Lasgouttes wrote: > Second try, now that I read the code: change the converter flag "latex" to > take the form "latex=xetex" or whatever to indicate the latex flavor that > we want. "latex" will be equivalent to "latex=latex". > > With this, the information does not need to be hardcoded anymore.
A patch along this line is attached. We still have to hardcode xhtml, since there's no dedicated converter where we could derive a xhtml flag from. Jürgen
Index: lib/configure.py =================================================================== --- lib/configure.py (Revision 36573) +++ lib/configure.py (Arbeitskopie) @@ -391,7 +391,7 @@ # run platex on chklatex.ltx and check result if cmdOutput(PLATEX + ' chklatex.ltx').find('pLaTeX2e') != -1: # We have the Japanese pLaTeX2e - addToRC(r'\converter platex dvi "%s" "latex"' % PLATEX) + addToRC(r'\converter platex dvi "%s" "latex=platex"' % PLATEX) else: PLATEX = '' removeFiles(['chklatex.ltx', 'chklatex.log']) @@ -590,16 +590,16 @@ def checkConverterEntries(): ''' Check all converters (\converter entries) ''' checkProg('the pdflatex program', ['pdflatex $$i'], - rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex"' ]) + rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex=pdflatex"' ]) checkProg('XeTeX', ['xelatex $$i'], - rc_entry = [ r'\converter xetex pdf4 "%%" "latex"' ]) + rc_entry = [ r'\converter xetex pdf4 "%%" "latex=xelatex"' ]) checkProg('LuaTeX', ['lualatex $$i'], - rc_entry = [ r'\converter luatex pdf5 "%%" "latex"' ]) + rc_entry = [ r'\converter luatex pdf5 "%%" "latex=lualatex"' ]) checkProg('LuaTeX (DVI)', ['dvilualatex $$i'], - rc_entry = [ r'\converter luatex dvi3 "%%" "latex"' ]) + rc_entry = [ r'\converter luatex dvi3 "%%" "latex=lualatex"' ]) ''' If we're running LyX in-place then tex2lyx will be found in ../src/tex2lyx. Add this directory to the PATH temporarily and Index: src/Converter.h =================================================================== --- src/Converter.h (Revision 36573) +++ src/Converter.h (Arbeitskopie) @@ -53,6 +53,8 @@ /// The converter is latex or its derivatives bool latex; + /// The latex derivate + std::string latex_flavor; /// The converter is xml bool xml; /// This converter needs the .aux files Index: src/Converter.cpp =================================================================== --- src/Converter.cpp (Revision 36573) +++ src/Converter.cpp (Arbeitskopie) @@ -108,9 +108,10 @@ string flag_name, flag_value; flag_list = split(flag_list, flag_value, ','); flag_value = split(flag_value, flag_name, '='); - if (flag_name == "latex") + if (flag_name == "latex") { latex = true; - else if (flag_name == "xml") + latex_flavor = flag_value; + } else if (flag_name == "xml") xml = true; else if (flag_name == "needaux") need_aux = true; @@ -255,11 +256,11 @@ cit != path.end(); ++cit) { Converter const & conv = converterlist_[*cit]; if (conv.latex) - if (contains(conv.from, "xetex")) + if (conv.latex_flavor == "xelatex") return OutputParams::XETEX; - if (contains(conv.from, "luatex")) + if (conv.latex_flavor == "lualatex") return OutputParams::LUATEX; - if (contains(conv.to, "pdf")) + if (conv.latex_flavor == "pdflatex") return OutputParams::PDFLATEX; if (conv.xml) return OutputParams::XML; Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (Revision 36573) +++ src/Buffer.cpp (Arbeitskopie) @@ -3048,8 +3048,28 @@ { OutputParams runparams(¶ms().encoding()); runparams.nice = true; - runparams.flavor = params().useNonTeXFonts ? - OutputParams::XETEX : OutputParams::LATEX; + + string const dformat = getDefaultOutputFormat(); + if (dformat == "xhtml") + runparams.flavor = OutputParams::HTML; + else { + // Try to determine flavor of default output format + vector<string> backs = backends(); + if (find(backs.begin(), backs.end(), dformat) == backs.end()) { + // Get shortest path to format + Graph::EdgePath path; + for (vector<string>::const_iterator it = backs.begin(); + it != backs.end(); ++it) { + Graph::EdgePath p = theConverters().getPath(*it, dformat); + if (!p.empty() && (path.empty() || p.size() < path.size())) { + path = p; + } + } + if (!path.empty()) + runparams.flavor = theConverters().getFlavor(path); + } + } + runparams.linelen = lyxrc.plaintext_linelen; // No side effect of file copying and image conversion runparams.dryrun = true; @@ -3061,6 +3081,8 @@ d->texrow.newline(); if (isDocBook()) writeDocBookSource(os, absFileName(), runparams, false); + else if (runparams.flavor == OutputParams::HTML) + writeLyXHTMLSource(os, runparams, false); else // latex or literate writeLaTeXSource(os, string(), runparams, true, true); @@ -3085,7 +3107,10 @@ // output paragraphs if (isDocBook()) docbookParagraphs(text(), *this, os, runparams); - else + else if (runparams.flavor == OutputParams::HTML) { + XHTMLStream xs(os); + xhtmlParagraphs(text(), *this, xs, runparams); + } else // latex or literate latexParagraphs(*this, text(), os, texrow, runparams); }