diff --git a/lib/configure.py b/lib/configure.py index f81aa3aad8..132141dc3a 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -901,7 +901,7 @@ def checkConverterEntries(): path, t2l = checkProg('a LaTeX/Noweb -> LyX converter', [quoteIfSpace(in_binary_subdir), quoteIfSpace(in_binary_subdir + version_suffix), quoteIfSpace(in_binary_dir), quoteIfSpace(in_binary_dir + version_suffix), 'tex2lyx' + version_suffix, 'tex2lyx'], rc_entry = [r'''\converter latex lyx "%% -f $$i $$o" "" -\converter latexclipboard lyx "%% -fixedenc utf8 -f $$i $$o" "" +\converter latexclipboard lyx "%% -fixedenc utf8 -c $$c -m $$m -f $$i $$o" "" \converter literate lyx "%% -n -m noweb -f $$i $$o" "" \converter sweave lyx "%% -n -m sweave -f $$i $$o" "" \converter knitr lyx "%% -n -m knitr -f $$i $$o" ""'''], not_found = 'tex2lyx') diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 1867e75513..96005b9215 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -1145,7 +1145,7 @@ bool Buffer::importFile(string const & format, FileName const & name, ErrorList FileName const lyx = tempFileName("Buffer_importFileXXXXXX.lyx"); Converters::RetVal const retval = - theConverters().convert(nullptr, name, lyx, name, format, "lyx", errorList); + theConverters().convert(this, name, lyx, name, format, "lyx", errorList); if (retval == Converters::SUCCESS) { bool const success = readFile(lyx) == ReadSuccess; removeTempFile(lyx); diff --git a/src/Converter.cpp b/src/Converter.cpp index 7bb998d5a9..172b2a2091 100644 --- a/src/Converter.cpp +++ b/src/Converter.cpp @@ -15,6 +15,7 @@ #include "Buffer.h" #include "BufferParams.h" #include "ConverterCache.h" +#include "TextClass.h" #include "Encoding.h" #include "ErrorList.h" #include "Format.h" @@ -58,6 +59,8 @@ string const token_to("$$o"); string const token_path("$$p"); string const token_orig_path("$$r"); string const token_orig_from("$$f"); +string const token_textclass("$$c"); +string const token_modules("$$m"); string const token_encoding("$$e"); string const token_latex_encoding("$$E"); string const token_python("$${python}"); @@ -472,7 +475,7 @@ Converters::RetVal Converters::convert(Buffer const * buffer, return FAILURE; } - // buffer is only invalid for importing, and then runparams is not + // buffer can only be null for importing, and then runparams is not // used anyway. OutputParams runparams(buffer ? &buffer->params().encoding() : nullptr); runparams.flavor = getFlavor(edgepath, buffer); @@ -649,7 +652,15 @@ Converters::RetVal Converters::convert(Buffer const * buffer, command = subst(command, token_path, quoteName(onlyPath(infile.absFileName()))); 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_encoding, buffer ? buffer->params().encoding().iconvName() : string()); + command = subst(command, token_textclass, + buffer ? quoteName(buffer->params().documentClass().name()) + : string()); + command = subst(command, token_modules, + buffer ? quoteName(buffer->params().getModules().asString()) + : string()); + command = subst(command, token_encoding, + buffer ? quoteName(buffer->params().encoding().iconvName()) + : string()); command = subst(command, token_python, os::python()); if (!conv.parselog().empty()) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index f79d4ace7c..f127f1b1f6 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -1299,6 +1299,7 @@ bool pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs, Buffer buffer(string(), false); buffer.setInternal(true); buffer.setUnnamed(true); + buffer.params() = cur.buffer()->params(); available = buffer.importString(names[i], text, errorList); if (available) available = !buffer.paragraphs().empty(); diff --git a/src/LayoutModuleList.cpp b/src/LayoutModuleList.cpp index b2e9067ed2..de1324ccb5 100644 --- a/src/LayoutModuleList.cpp +++ b/src/LayoutModuleList.cpp @@ -53,6 +53,18 @@ bool LayoutModuleList::adaptToBaseClass(LayoutFile const * const lay, } +string LayoutModuleList::asString() const +{ + string mods; + for (auto const & mod : lml_) + mods += mod + ','; + // remove trailing comma + if (!mods.empty()) + mods.pop_back(); + return mods; +} + + bool LayoutModuleList::moduleCanBeAdded(string const & modName, LayoutFile const * const lay) const { diff --git a/src/LayoutModuleList.h b/src/LayoutModuleList.h index 6018029aa8..babd760229 100644 --- a/src/LayoutModuleList.h +++ b/src/LayoutModuleList.h @@ -55,6 +55,8 @@ public: /// This is needed in GuiDocument. It seems better than an /// implicit conversion. std::list const & list() const { return lml_; } + /// List of modules as a comma-separated string + std::string asString() const; /// Checks to make sure module's requriements are satisfied, that it does /// not conflict with already-present modules, isn't already loaded, etc. bool moduleCanBeAdded(std::string const & modName,