mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Update tex2lyx and tests after 306b136c
This commit is contained in:
parent
306b136cc0
commit
7144f8dad8
@ -1046,7 +1046,7 @@ void Preamble::handle_if(Parser & p, bool in_lyx_preamble)
|
||||
}
|
||||
|
||||
|
||||
bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
|
||||
bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiledir)
|
||||
{
|
||||
// set the quote language
|
||||
// LyX only knows the following quotes languages:
|
||||
@ -1088,11 +1088,13 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
|
||||
// output the LyX file settings
|
||||
// Important: Keep the version formatting in sync with LyX and
|
||||
// lyx2lyx (bug 7951)
|
||||
string const origin = roundtripMode() ? "roundtrip" : outfiledir;
|
||||
os << "#LyX file created by tex2lyx " << lyx_version_major << '.'
|
||||
<< lyx_version_minor << '\n'
|
||||
<< "\\lyxformat " << LYX_FORMAT << '\n'
|
||||
<< "\\begin_document\n"
|
||||
<< "\\begin_header\n"
|
||||
<< "\\origin " << origin << "\n"
|
||||
<< "\\textclass " << h_textclass << "\n";
|
||||
string const raw = subdoc ? empty_string() : h_preamble.str();
|
||||
if (!raw.empty()) {
|
||||
|
@ -93,7 +93,8 @@ public:
|
||||
void parse(Parser & p, std::string const & forceclass,
|
||||
TeX2LyXDocClass & tc);
|
||||
/// Writes the LyX file header from internal data
|
||||
bool writeLyXHeader(std::ostream & os, bool subdoc);
|
||||
bool writeLyXHeader(std::ostream & os, bool subdoc,
|
||||
std::string const & outfiledir);
|
||||
|
||||
/// known polyglossia language names (including variants)
|
||||
static const char * const polyglossia_languages[];
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
\usepackage{babel}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
\usepackage{babel}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\use_default_options false
|
||||
\maintain_unincluded_children false
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\use_default_options false
|
||||
\maintain_unincluded_children false
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass memoir
|
||||
\begin_preamble
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass amsart
|
||||
\begin_preamble
|
||||
\usepackage{babel}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass book
|
||||
\begin_preamble
|
||||
\usepackage{babel}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass scrbook
|
||||
\begin_preamble
|
||||
\usepackage{babel}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
%% Special footnote code from the package 'stblftnt.sty'
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\begin_preamble
|
||||
% This is a test document for tex2lyx
|
||||
|
@ -1,7 +1,8 @@
|
||||
#LyX file created by tex2lyx 2.2
|
||||
\lyxformat 489
|
||||
\lyxformat 490
|
||||
\begin_document
|
||||
\begin_header
|
||||
\origin roundtrip
|
||||
\textclass article
|
||||
\use_default_options false
|
||||
\maintain_unincluded_children false
|
||||
|
@ -839,7 +839,8 @@ namespace {
|
||||
* You must ensure that \p parentFilePathTeX is properly set before calling
|
||||
* this function!
|
||||
*/
|
||||
bool tex2lyx(idocstream & is, ostream & os, string encoding)
|
||||
bool tex2lyx(idocstream & is, ostream & os, string encoding,
|
||||
string const & outfiledir)
|
||||
{
|
||||
// Set a sensible default encoding.
|
||||
// This is used until an encoding command is found.
|
||||
@ -905,7 +906,7 @@ bool tex2lyx(idocstream & is, ostream & os, string encoding)
|
||||
for (; it != end; ++it)
|
||||
preamble.addModule(*it);
|
||||
}
|
||||
if (!preamble.writeLyXHeader(os, !active_environments.empty())) {
|
||||
if (!preamble.writeLyXHeader(os, !active_environments.empty(), outfiledir)) {
|
||||
cerr << "Could not write LyX file header." << endl;
|
||||
return false;
|
||||
}
|
||||
@ -924,7 +925,8 @@ bool tex2lyx(idocstream & is, ostream & os, string encoding)
|
||||
|
||||
|
||||
/// convert TeX from \p infilename to LyX and write it to \p os
|
||||
bool tex2lyx(FileName const & infilename, ostream & os, string const & encoding)
|
||||
bool tex2lyx(FileName const & infilename, ostream & os, string const & encoding,
|
||||
string const & outfiledir)
|
||||
{
|
||||
ifdocstream is;
|
||||
// forbid buffering on this stream
|
||||
@ -937,7 +939,7 @@ bool tex2lyx(FileName const & infilename, ostream & os, string const & encoding)
|
||||
}
|
||||
string const oldParentFilePath = parentFilePathTeX;
|
||||
parentFilePathTeX = onlyPath(infilename.absFileName());
|
||||
bool retval = tex2lyx(is, os, encoding);
|
||||
bool retval = tex2lyx(is, os, encoding, outfiledir);
|
||||
parentFilePathTeX = oldParentFilePath;
|
||||
return retval;
|
||||
}
|
||||
@ -970,7 +972,8 @@ bool tex2lyx(string const & infilename, FileName const & outfilename,
|
||||
cerr << "Input file: " << infilename << "\n";
|
||||
cerr << "Output file: " << outfilename << "\n";
|
||||
#endif
|
||||
return tex2lyx(FileName(infilename), os, encoding);
|
||||
return tex2lyx(FileName(infilename), os, encoding,
|
||||
outfilename.onlyPath().absFileName() + '/');
|
||||
}
|
||||
|
||||
|
||||
@ -1122,7 +1125,7 @@ int TeX2LyXApp::run()
|
||||
if (outfilename == "-") {
|
||||
// assume same directory as input file
|
||||
masterFilePathLyX = masterFilePathTeX;
|
||||
if (tex2lyx(FileName(infilename), cout, default_encoding))
|
||||
if (tex2lyx(FileName(infilename), cout, default_encoding, masterFilePathLyX))
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
masterFilePathLyX = onlyPath(outfilename);
|
||||
|
Loading…
Reference in New Issue
Block a user