diff --git a/src/Buffer.cpp b/src/Buffer.cpp index c0723bea05..618b7d18a1 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3317,7 +3317,13 @@ void Buffer::getSourceCode(odocstream & os, string const format, << "\n\n"; } // output paragraphs - if (runparams.flavor == OutputParams::HTML) { + if (runparams.flavor == OutputParams::LYX) { + Paragraph const & par = text().paragraphs()[par_begin]; + ostringstream ods; + depth_type dt = par.getDepth(); + par.write(ods, params(), dt); + os << from_utf8(ods.str()); + } else if (runparams.flavor == OutputParams::HTML) { XHTMLStream xs(os); setMathFlavor(runparams); xhtmlParagraphs(text(), *this, xs, runparams); @@ -3347,7 +3353,16 @@ void Buffer::getSourceCode(odocstream & os, string const format, else if (output == OnlyBody) os << _("Preview body"); os << "\n\n"; - if (runparams.flavor == OutputParams::HTML) { + if (runparams.flavor == OutputParams::LYX) { + ostringstream ods; + if (output == FullSource) + write(ods); + else if (output == OnlyPreamble) + params().writeFile(ods); + else if (output == OnlyBody) + text().write(ods); + os << from_utf8(ods.str()); + } else if (runparams.flavor == OutputParams::HTML) { writeLyXHTMLSource(os, runparams, output); } else if (runparams.flavor == OutputParams::TEXT) { if (output == OnlyPreamble) { diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 817403f0de..bfee4cff3f 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2180,6 +2180,8 @@ OutputParams::FLAVOR BufferParams::getOutputFlavor(string const format) const result = OutputParams::HTML; else if (dformat == "text") result = OutputParams::TEXT; + else if (dformat == "lyx") + result = OutputParams::LYX; else { // Try to determine flavor of default output format vector backs = backends(); diff --git a/src/OutputParams.h b/src/OutputParams.h index 15736f667d..d3c2921b46 100644 --- a/src/OutputParams.h +++ b/src/OutputParams.h @@ -35,7 +35,8 @@ public: XETEX, XML, HTML, - TEXT + TEXT, + LYX }; enum MathFlavor { diff --git a/src/frontends/qt4/GuiViewSource.cpp b/src/frontends/qt4/GuiViewSource.cpp index 286055c407..f4f197d1de 100644 --- a/src/frontends/qt4/GuiViewSource.cpp +++ b/src/frontends/qt4/GuiViewSource.cpp @@ -209,9 +209,6 @@ void ViewSourceWidget::updateDefaultFormat() LYXERR0("Can't find format for backend " << format << "!"); continue; } - if (fmt->name() == "lyx") - // we can't presently display the LyX format itself - continue; QString const pretty = qt_(fmt->prettyname()); QString const qformat = toqstr(format); diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 54b04b3946..ea51664978 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -752,6 +752,9 @@ void InsetExternal::validate(LaTeXFeatures & features) const case OutputParams::TEXT: format = "text"; break; + case OutputParams::LYX: + format = "lyx"; + break; } external::Template::Formats::const_iterator cit = et.formats.find(format);