Am Sun, 16 Oct 2022 15:53:05 +0200
schrieb Kornel Benko <kor...@lyx.org>:

> Am Fri, 14 Oct 2022 23:02:47 -0400
> schrieb Scott Kostyshak <skost...@lyx.org>:
> 
> > On Mon, Jul 18, 2022 at 11:44:05PM +0200, Jean-Marc Lasgouttes wrote:  
> > > commit 96e7fcd4e0c600c3dd99e901ff84ff1480167cf8
> > > Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
> > > Date:   Mon Jul 18 00:50:33 2022 +0200
> > > 
> > >     When pasting as LaTeX, honor textclass and modules
> > >     
> > >     There are several small parts that are needed here:
> > >     
> > >     * Implement LayoutModuleList::asString() that returns a 
> > > comma-separated
> > >       list of modules.
> > >     
> > >     * in Converter::convert(), handle the new tokens $$c for the current
> > >       textclass and $$m for the list of modules.
> > >     
> > >     * in Buffer::importFile(), pass the current buffer as parameter 
> > > instead
> > >       of nullptr.
> > >     
> > >     * in pasteClipboardText(), copy the parameters of the current buffer 
> > > to
> > >       the internal one used for importation, so that the textclass and
> > >       modules information is available to convert().
> > >     
> > >     * finally, modify configure.py to pass "-c $$c -m $$m" to tex2lyx for
> > >       the latexclipoard->lyx converter.
> > >     
> > >     Fixes bug #11312.
> > > ---    
> > 
> > Starting with this commit, "Paste from LaTeX" no longer seems to work
> > for me. I get the following in the terminal:
> > 
> >   Creating file /tmp/lyx_tmpdir.sJMMXUAnpRwt/Buffer_importStringMMGtph.lyx
> >   Cannot read layout file `'.
> >   Error: Could not load module "-f".
> >   support/Systemcall.cpp (306): Systemcall: 'tex2lyx -fixedenc utf8 -c 
> > "article" -m ""
> > -f "Buffer_importStringMMGtph.tex" "Buffer_importStringMMGtph.lyx"' 
> > finished with exit
> > code 1 Error: Cannot convert file ----------------------------------------
> >   An error occurred while running:
> >   tex2lyx -fixedenc utf8 -c "article" -m "" -f 
> > "Buffer_importStringMMGtph.tex"
> >   "Buffer_importStringMMGtph.lyx"
> > 
> > Scott  
> 
> The placeholder $$m may be empty, but the parameter '-m' still requires a 
> value. Maybe
> this patch helps?
> BTW, I was unable to 'Paste from LaTeX' to a new document. (Missing this 
> dialog entry in
> Edit->Paste Special)

With a clipboard I get this dialog now. And have a working workaround.
If no modules are present, so using the fixme module to feed the tex2lyx with 
does the
job.

We may need either
1.) a dummy module
or
2.) correct tex2lyx to accept "" as module-list


        Kornel

diff --git a/src/Converter.cpp b/src/Converter.cpp
index 172b2a2091..c23a085709 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -653,13 +653,16 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
 			command = subst(command, token_orig_path, quoteName(onlyPath(orig_from.absFileName())));
 			command = subst(command, token_orig_from, quoteName(onlyFileName(orig_from.absFileName())));
 			command = subst(command, token_textclass,
 			                buffer ? quoteName(buffer->params().documentClass().name())
 			                       : string());
-			command = subst(command, token_modules,
-			                buffer ? quoteName(buffer->params().getModules().asString())
-			                       : string());
+			{
+				string module = buffer ? quoteName(buffer->params().getModules().asString()) : string();
+				if (module.empty() || module.compare("\"\"") == 0)
+					module = string("\"fixme\"");
+				command = subst(command, token_modules, module);
+			}
 			command = subst(command, token_encoding,
 			                buffer ? quoteName(buffer->params().encoding().iconvName())
 			                       : string());
 			command = subst(command, token_python, os::python());
 

Attachment: pgpW12gerM1vB.pgp
Description: Digitale Signatur von OpenPGP

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to