+ // Do not output empty environments if the whole paragraph has
+ // been deleted with ct and changes are not output.
+ if (size_t(pit + 1) < paragraphs.size()) {
+ ParagraphList::const_iterator nextpar = paragraphs.constIterator(pit + 1);
+ Paragraph const & cpar = paragraphs.at(pit);
+ if ((par->layout() != nextpar->layout()
+ || par->params().depth() == nextpar->params().depth()
+ || par->params().leftIndent() == nextpar->params().leftIndent())
+ && !runparams.for_search && cpar.size() > 0
+ && cpar.isDeleted(0, cpar.size()) && !buf.params().output_changes) {
+ if (!buf.params().output_changes && !cpar.parEndChange().deleted())
+ os << '\n' << '\n';
+ continue;
+ }
+ }
+
// This is a new environment.
TeXEnvironmentData const data =
prepareEnvironment(buf, text, par, os, runparams);
// This is a new environment.
TeXEnvironmentData const data =
prepareEnvironment(buf, text, par, os, runparams);
+ // Do not output empty commands if the whole paragraph has
+ // been deleted with ct and changes are not output.
+ if (!runparams_in.for_search && style.latextype != LATEX_ENVIRONMENT
+ && par.size() > 0 && par.isDeleted(0, par.size()) && !bparams.output_changes)
+ return;
+
if (text.inset().isPassThru()) {
Font const outerfont = text.outerFont(pit);
// No newline before first paragraph in this lyxtext
if (text.inset().isPassThru()) {
Font const outerfont = text.outerFont(pit);
// No newline before first paragraph in this lyxtext
- bool const intitle_command = style.intitle && style.latextype == LATEX_COMMAND;
+ bool const intitle_command = style.intitle && style.isCommand();
+ // Intitle commands switch languages locally, thus increase
+ // language nesting level
+ if (intitle_command)
+ state->nest_level_ += 1;
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
if (par.needsCProtection(runparams.moving_arg)
&& contains(runparams.active_chars, '^'))
os << "\\endgroup";
if (par.needsCProtection(runparams.moving_arg)
&& contains(runparams.active_chars, '^'))
os << "\\endgroup";
os << '\n';
} else if (nextpar && !style.isEnvironment()) {
Layout const nextstyle = text.inset().forcePlainLayout()
? bparams.documentClass().plainLayout()
: nextpar->layout();
os << '\n';
} else if (nextpar && !style.isEnvironment()) {
Layout const nextstyle = text.inset().forcePlainLayout()
? bparams.documentClass().plainLayout()
: nextpar->layout();
&& priorpar->layout().isEnvironment()
&& (priorpar->getDepth() > par.getDepth()
|| (priorpar->getDepth() == par.getDepth()
&& priorpar->layout().isEnvironment()
&& (priorpar->getDepth() > par.getDepth()
|| (priorpar->getDepth() == par.getDepth()
- && priorpar->layout() != par.layout()));
+ && priorpar->layout() != par.layout()));
+
+ // We need to ignore previous intitle commands since languages
+ // are switched locally there (# 11514)
+ // There might be paragraphs before the title, so we check this.
+ Paragraph * prior_nontitle_par = nullptr;
+ if (!intitle_command) {
+ pit_type ppit = pit;
+ while (ppit > 0) {
+ --ppit;
+ Paragraph const * tmppar = ¶graphs.at(ppit);
+ if (tmppar->layout().intitle && tmppar->layout().isCommand())
+ continue;
+ prior_nontitle_par = const_cast<Paragraph*>(tmppar);
+ break;
+ }
+ }
- runparams_in.for_search ?
- languages.getLanguage("ignore")
- :(priorpar && !priorpar->isPassThru())
- ? (use_prev_env_language ? state->prev_env_language_
- : priorpar->getParLanguage(bparams))
- : outer_language;
+ runparams_in.for_search
+ ? languages.getLanguage("ignore")
+ : (prior_nontitle_par && !prior_nontitle_par->isPassThru())
+ ? (use_prev_env_language
+ ? state->prev_env_language_
+ : prior_nontitle_par->getParLanguage(bparams))
+ : outer_language;
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
&& runparams.local_font != nullptr
&& outer_language->rightToLeft()
&& !par_language->rightToLeft();
&& runparams.local_font != nullptr
&& outer_language->rightToLeft()
&& !par_language->rightToLeft();
&& !par_lang.empty()) {
string bc = use_polyglossia ?
getPolyglossiaBegin(lang_begin_command, par_lang,
&& !par_lang.empty()) {
string bc = use_polyglossia ?
getPolyglossiaBegin(lang_begin_command, par_lang,
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
&& nextpar->getDepth() < par.getDepth()))
close_lang_switch = using_begin_end;
if (nextpar && par.params().depth() < nextpar->params().depth())
&& nextpar->getDepth() < par.getDepth()))
close_lang_switch = using_begin_end;
if (nextpar && par.params().depth() < nextpar->params().depth())
default:
// we don't need it for the last paragraph and in InTitle commands!!!
if (nextpar && !intitle_command)
default:
// we don't need it for the last paragraph and in InTitle commands!!!
if (nextpar && !intitle_command)
- if (is_command) {
- os << '}';
- if (!style.postcommandargs().empty())
- latexArgInsets(par, os, runparams, style.postcommandargs(), "post:");
- if (!runparams.post_macro.empty()) {
- // Output the stored fragile commands (labels, indices etc.)
- // that need to be output after the command with moving argument.
- os << runparams.post_macro;
- runparams.post_macro.clear();
- }
- if (par.needsCProtection(runparams.moving_arg)
- && contains(runparams.active_chars, '^'))
- os << "\\endgroup";
- if (runparams.encoding != prev_encoding) {
- runparams.encoding = prev_encoding;
- os << setEncoding(prev_encoding->iconvName());
- }
+ os << '}';
+ if (!style.postcommandargs().empty())
+ latexArgInsets(par, os, runparams, style.postcommandargs(), "post:");
+ if (!runparams.post_macro.empty()) {
+ // Output the stored fragile commands (labels, indices etc.)
+ // that need to be output after the command with moving argument.
+ os << runparams.post_macro;
+ runparams.post_macro.clear();
+ }
+ if (par.needsCProtection(runparams.moving_arg)
+ && contains(runparams.active_chars, '^'))
+ os << "\\endgroup";
+ if (runparams.encoding != prev_encoding) {
+ runparams.encoding = prev_encoding;
+ os << setEncoding(prev_encoding->iconvName());
+ // Signify added/deleted par break in output if show changes in output
+ if (nextpar && !os.afterParbreak() && !last_was_separator
+ && bparams.output_changes && par.parEndChange().changed()) {
+ Changes::latexMarkChange(os, bparams, Change(Change::UNCHANGED),
+ par.parEndChange(), runparams);
+ os << bparams.encoding().latexString(docstring(1, 0x00b6)).first << "}";
+ }
+
// TeXEnvironment, because it is needed in this case
if (nextpar && !os.afterParbreak() && !last_was_separator) {
Layout const & next_layout = nextpar->layout();
// TeXEnvironment, because it is needed in this case
if (nextpar && !os.afterParbreak() && !last_was_separator) {
Layout const & next_layout = nextpar->layout();
// Make sure to start a new line
os << breakln;
// A newline '\n' is always output before a command,
// Make sure to start a new line
os << breakln;
// A newline '\n' is always output before a command,
&& next_layout.align == nextpar->getAlign(bparams))
|| (style.align != par.getAlign(bparams)
&& tclass.isDefaultLayout(next_layout))) {
&& next_layout.align == nextpar->getAlign(bparams))
|| (style.align != par.getAlign(bparams)
&& tclass.isDefaultLayout(next_layout))) {
LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " done; ptr "
<< &par << " next " << nextpar);
LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " done; ptr "
<< &par << " next " << nextpar);
+ // Do not output empty environments if the whole paragraph has
+ // been deleted with ct and changes are not output.
+ if (size_t(pit + 1) < paragraphs.size()) {
+ ParagraphList::const_iterator nextpar = paragraphs.constIterator(pit + 1);
+ Paragraph const & cpar = paragraphs.at(pit);
+ if ((par->layout() != nextpar->layout()
+ || par->params().depth() == nextpar->params().depth()
+ || par->params().leftIndent() == nextpar->params().leftIndent())
+ && !runparams.for_search && cpar.size() > 0
+ && cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) {
+ if (!bparams.output_changes && !cpar.parEndChange().deleted())
+ os << '\n' << '\n';
+ continue;
+ }
+ }
+
TeXEnvironmentData const data =
prepareEnvironment(buf, text, par, os, runparams);
// pit can be changed in TeXEnvironment.
TeXEnvironmentData const data =
prepareEnvironment(buf, text, par, os, runparams);
// pit can be changed in TeXEnvironment.