mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Allow InPreamble to be used with Paragraph-type environments. There is
no reason not to permit this, and using it with PassThru 1 allows for a very simple Preamble layout-type that acts as ERT for the premable. Of course, we do have the preamble in Document>Settings, but that allows the embedding of preamble code in branches. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36562 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
746fb55c9b
commit
a61899ffe7
@ -1,5 +1,5 @@
|
||||
#LyX 2.0.0svn created this file. For more info see http://www.lyx.org/
|
||||
\lyxformat 404
|
||||
\lyxformat 410
|
||||
\begin_document
|
||||
\begin_header
|
||||
\textclass scrbook
|
||||
@ -76,7 +76,7 @@ End
|
||||
\font_sans default
|
||||
\font_typewriter default
|
||||
\font_default_family default
|
||||
\use_xetex false
|
||||
\use_non_tex_fonts false
|
||||
\font_sc false
|
||||
\font_osf false
|
||||
\font_sf_scale 100
|
||||
@ -138,6 +138,7 @@ End
|
||||
\html_math_output 0
|
||||
\html_be_strict true
|
||||
\author 1 "Jean-Marc Lasgouttes"
|
||||
\author 223010757 "Richard Heck" rgheck@brown.edu
|
||||
\end_header
|
||||
|
||||
\begin_body
|
||||
@ -10181,6 +10182,24 @@ Command
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\change_inserted 223010757 1290981996
|
||||
or
|
||||
\begin_inset Flex Code
|
||||
status collapsed
|
||||
|
||||
\begin_layout Plain Layout
|
||||
|
||||
\change_inserted 223010757 1290981998
|
||||
Paragraph
|
||||
\change_unchanged
|
||||
|
||||
\end_layout
|
||||
|
||||
\end_inset
|
||||
|
||||
|
||||
\change_unchanged
|
||||
.
|
||||
\end_layout
|
||||
|
||||
|
@ -577,8 +577,8 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
|
||||
}
|
||||
lex.popTable();
|
||||
// make sure we only have inpreamble = true for commands
|
||||
if (inpreamble && latextype != LATEX_COMMAND) {
|
||||
LYXERR0("InPreamble not permitted except with Command-type layouts.");
|
||||
if (inpreamble && latextype != LATEX_COMMAND && latextype != LATEX_PARAGRAPH) {
|
||||
LYXERR0("InPreamble not permitted except with command and paragraph layouts.");
|
||||
LYXERR0("Layout name: " << name());
|
||||
inpreamble = false;
|
||||
}
|
||||
|
@ -1328,6 +1328,7 @@ bool Paragraph::Private::latexSpecialPhrase(odocstream & os, pos_type & i,
|
||||
void Paragraph::Private::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
if (layout_->inpreamble && inset_owner_) {
|
||||
bool const is_command = layout_->latextype == LATEX_COMMAND;
|
||||
Buffer const & buf = inset_owner_->buffer();
|
||||
BufferParams const & bp = buf.params();
|
||||
Font f;
|
||||
@ -1337,20 +1338,23 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
|
||||
// output is wrong if this paragraph contains content
|
||||
// that needs to switch encoding.
|
||||
odocstringstream ods;
|
||||
ods << '\\' << from_ascii(layout_->latexname());
|
||||
// we have to provide all the optional arguments here, even though
|
||||
// the last one is the only one we care about.
|
||||
// Separate handling of optional argument inset.
|
||||
if (layout_->optargs != 0 || layout_->reqargs != 0)
|
||||
latexArgInsets(*owner_, ods, features.runparams(),
|
||||
layout_->reqargs, layout_->optargs);
|
||||
else
|
||||
ods << from_ascii(layout_->latexparam());
|
||||
if (is_command) {
|
||||
ods << '\\' << from_ascii(layout_->latexname());
|
||||
// we have to provide all the optional arguments here, even though
|
||||
// the last one is the only one we care about.
|
||||
// Separate handling of optional argument inset.
|
||||
if (layout_->optargs != 0 || layout_->reqargs != 0)
|
||||
latexArgInsets(*owner_, ods, features.runparams(),
|
||||
layout_->reqargs, layout_->optargs);
|
||||
else
|
||||
ods << from_ascii(layout_->latexparam());
|
||||
}
|
||||
docstring::size_type const length = ods.str().length();
|
||||
// this will output "{" at the beginning, but not at the end
|
||||
owner_->latex(bp, f, ods, tr, features.runparams(), 0, -1, true);
|
||||
if (ods.str().length() > length) {
|
||||
ods << '}';
|
||||
if (is_command)
|
||||
ods << '}';
|
||||
string const snippet = to_utf8(ods.str());
|
||||
features.addPreambleSnippet(snippet);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user