}
-static void finishEnvironment(Buffer const & buf, Text const & text,
- pit_type nextpit, otexstream & os,
- OutputParams const & runparams,
+static void finishEnvironment(otexstream & os, OutputParams const & runparams,
TeXEnvironmentData const & data)
{
if (open_encoding_ == CJK && data.cjk_nested) {
}
// Check whether we should output a blank line after the environment
- DocumentClass const & tclass = buf.params().documentClass();
- ParagraphList const & pars = text.paragraphs();
- bool next_style_is_default = (nextpit >= runparams.par_end) ? false
- : tclass.isDefaultLayout(pars.constIterator(nextpit)->layout());
- if (!data.style->nextnoindent && next_style_is_default)
+ if (!data.style->nextnoindent)
os << '\n';
}
prepareEnvironment(buf, text, par, os, runparams);
// Recursive call to TeXEnvironment!
TeXEnvironment(buf, text, runparams, pit, os);
- finishEnvironment(buf, text, pit + 1, os, runparams, data);
+ finishEnvironment(os, runparams, data);
}
if (pit != runparams.par_end)
if (argnr == 0)
return;
+ // Default and preset args are always output, so if they require
+ // other arguments, consider this.
+ Layout::LaTeXArgMap::const_iterator lit = latexargs.begin();
+ Layout::LaTeXArgMap::const_iterator const lend = latexargs.end();
+ for (; lit != lend; ++lit) {
+ Layout::latexarg arg = (*lit).second;
+ if ((!arg.presetarg.empty() || !arg.defaultarg.empty()) && !arg.requires.empty()) {
+ vector<string> req = getVectorFromString(arg.requires);
+ required.insert(required.end(), req.begin(), req.end());
+ }
+ }
+
for (unsigned int i = 1; i <= argnr; ++i) {
map<int, InsetArgument const *>::const_iterator lit = ilist.find(i);
bool inserted = false;
switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
- if (nextpar
- && (par.params().depth() < nextpar->params().depth())
- && !par.isEnvSeparator(par.size() - 1))
+ if (nextpar && par.params().depth() < nextpar->params().depth())
pending_newline = true;
break;
case LATEX_ENVIRONMENT: {
// fall through possible
default:
// we don't need it for the last paragraph!!!
- // or if the last thing is an environment separator
- if (nextpar && !par.isEnvSeparator(par.size() - 1))
+ if (nextpar)
pending_newline = true;
}
if (closing_rtl_ltr_environment)
os << "}";
+ bool const last_was_separator =
+ par.size() > 0 && par.isEnvSeparator(par.size() - 1);
+
if (pending_newline) {
if (unskip_newline)
// prevent unwanted whitespace
os << '%';
- os << '\n';
+ if (!os.afterParbreak() && !last_was_separator)
+ os << '\n';
}
// if this is a CJK-paragraph and the next isn't, close CJK
// we don't need a newline for the last paragraph!!!
// Note from JMarc: we will re-add a \n explicitly in
// TeXEnvironment, because it is needed in this case
- if (nextpar && !par.isEnvSeparator(par.size() - 1)) {
+ if (nextpar && !os.afterParbreak() && !last_was_separator) {
// Make sure to start a new line
os << breakln;
Layout const & next_layout = nextpar->layout();
// unchanged, or (case 2) the following is a
// non-environment paragraph whose depth is increased
// but whose alignment is unchanged, or (case 3) the
+ // paragraph is not an environment and the next one is a
+ // non-itemize-like env at lower depth, or (case 4) the
// paragraph is a command not followed by an environment
// and the alignment of the current and next paragraph
- // is unchanged, or (case 4) the current alignment is
+ // is unchanged, or (case 5) the current alignment is
// changed and a standard paragraph follows.
DocumentClass const & tclass = bparams.documentClass();
if ((style == next_layout
|| (!next_layout.isEnvironment()
&& nextpar->getDepth() > par.getDepth()
&& nextpar->getAlign() == par.getAlign())
+ || (!style.isEnvironment()
+ && next_layout.latextype == LATEX_ENVIRONMENT
+ && nextpar->getDepth() < par.getDepth())
|| (style.isCommand()
&& !next_layout.isEnvironment()
&& style.align == par.getAlign()
prepareEnvironment(buf, text, par, os, runparams);
// pit can be changed in TeXEnvironment.
TeXEnvironment(buf, text, runparams, pit, os);
- finishEnvironment(buf, text, pit + 1, os, runparams, data);
+ finishEnvironment(os, runparams, data);
}
if (pit == runparams.par_end) {