if (i + 1 < static_cast<pos_type>(text_.size()) &&
(end_pos == -1 || i + 1 < end_pos) &&
text_[i+1] == '-') {
- // Prevent "--" becoming an endash and "---" becoming
- // an emdash.
- // Within \ttfamily, "--" is merged to "-" (no endash)
- // so we avoid this rather irritating ligature as well
+ // Prevent "--" becoming an en dash and "---" an em dash.
+ // (Within \ttfamily, "---" is merged to en dash + hyphen.)
os << "{}";
column += 2;
}
// XeTeX's dash behaviour is determined via a global setting
if (bparams.use_dash_ligatures
&& owner_->getFontSettings(bparams, i).fontInfo().family() != TYPEWRITER_FAMILY
+ && !runparams.inIPA
+ // TODO #10961: && not in inset Flex Code
+ // TODO #10961: && not in layout LyXCode
&& (!bparams.useNonTeXFonts || runparams.flavor != OutputParams::XETEX)) {
if (c == 0x2013) {
// en-dash
os << "\\textvertline" << termcmd;
column += 14;
return true;
- case 0x2013:
- os << "\\textendash" << termcmd;
- column += 12;
- return true;
- case 0x2014:
- os << "\\textemdash" << termcmd;
- column += 12;
- return true;
default:
return false;
}
void Paragraph::Private::validate(LaTeXFeatures & features) const
{
- Buffer const & buf = inset_owner_->buffer();
- BufferParams const & bp = features.runparams().is_child
- ? buf.masterParams() : buf.params();
if (layout_->inpreamble && inset_owner_) {
- bool const is_command = layout_->latextype == LATEX_COMMAND;
- Font f;
- // Using a string stream here circumvents the encoding
+ // FIXME: Using a string stream here circumvents the encoding
// switching machinery of odocstream. Therefore the
// output is wrong if this paragraph contains content
// that needs to switch encoding.
+ Buffer const & buf = inset_owner_->buffer();
otexstringstream os;
os << layout_->preamble();
- if (is_command) {
- os << '\\' << 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_->latexargs().empty()) {
- OutputParams rp = features.runparams();
- rp.local_font = &owner_->getFirstFontSettings(bp);
- latexArgInsets(*owner_, os, rp, layout_->latexargs());
- }
- os << from_ascii(layout_->latexparam());
- }
size_t const length = os.length();
- // this will output "{" at the beginning, but not at the end
- owner_->latex(bp, f, os, features.runparams(), 0, -1, true);
- if (os.length() > length) {
- if (is_command) {
- os << '}';
- if (!layout_->postcommandargs().empty()) {
- OutputParams rp = features.runparams();
- rp.local_font = &owner_->getFirstFontSettings(bp);
- latexArgInsets(*owner_, os, rp, layout_->postcommandargs(), "post:");
- }
- }
+ TeXOnePar(buf, buf.text(), buf.getParFromID(owner_->id()).pit(), os,
+ features.runparams(), string(), 0, -1, true);
+ if (os.length() > length)
features.addPreambleSnippet(os.release(), true);
- }
}
if (features.runparams().flavor == OutputParams::HTML
}
// then the contents
+ BufferParams const bp = features.runparams().is_child
+ ? features.buffer().masterParams() : features.buffer().params();
for (pos_type i = 0; i < int(text_.size()) ; ++i) {
char_type c = text_[i];
if (c == 0x0022) {
void Paragraph::validate(LaTeXFeatures & features) const
{
d->validate(features);
+ if (needsCProtection())
+ features.require("cprotect");
}
// if the paragraph is empty, the loop will not be entered at all
if (empty()) {
- if (style.isCommand()) {
+ // For InTitle commands, we have already opened a group
+ // in output_latex::TeXOnePar.
+ if (style.isCommand() && !style.intitle) {
os << '{';
++column;
}
os << "}] ";
column +=3;
}
- if (style.isCommand()) {
+ // For InTitle commands, we have already opened a group
+ // in output_latex::TeXOnePar.
+ if (style.isCommand() && !style.intitle) {
os << '{';
++column;
}
ParagraphList const & pars =
textinset->text().paragraphs();
pit_type const pit = pars.size() - 1;
- Font const last_font =
+ Font const lastfont =
pit < 0 || pars[pit].empty()
? pars[pit].getLayoutFont(
bparams,
: pars[pit].getFont(bparams,
pars[pit].size() - 1,
outerfont);
- if (last_font.fontInfo().size() !=
+ if (lastfont.fontInfo().size() !=
basefont.fontInfo().size()) {
++parInline;
incremented = true;
}
+bool Paragraph::needsCProtection() const
+{
+ pos_type size = d->text_.size();
+ for (pos_type i = 0; i < size; ++i)
+ if (isInset(i))
+ return getInset(i)->needsCProtection();
+
+ return false;
+}
+
+
FontSpan const & Paragraph::getSpellRange(pos_type pos) const
{
return d->speller_state_.getRange(pos);
bool Paragraph::isMultiLingual(BufferParams const & bparams) const
{
Language const * doc_language = bparams.language;
- FontList::const_iterator cit = d->fontlist_.begin();
- FontList::const_iterator end = d->fontlist_.end();
-
- for (; cit != end; ++cit)
- if (cit->font().language() != ignore_language &&
- cit->font().language() != latex_language &&
- cit->font().language() != doc_language)
+ for (auto const & f : d->fontlist_)
+ if (f.font().language() != ignore_language &&
+ f.font().language() != latex_language &&
+ f.font().language() != doc_language)
return true;
return false;
}
-void Paragraph::getLanguages(std::set<Language const *> & languages) const
+void Paragraph::getLanguages(std::set<Language const *> & langs) const
{
- FontList::const_iterator cit = d->fontlist_.begin();
- FontList::const_iterator end = d->fontlist_.end();
-
- for (; cit != end; ++cit) {
- Language const * lang = cit->font().language();
+ for (auto const & f : d->fontlist_) {
+ Language const * lang = f.font().language();
if (lang != ignore_language &&
lang != latex_language)
- languages.insert(lang);
+ langs.insert(lang);
}
}
size_t tmplen = shorten ? maxlen + 1 : maxlen;
if (label && !labelString().empty())
os += labelString() + ' ';
+ if (!layout().isTocCaption())
+ return;
for (pos_type i = 0; i < size() && os.length() < tmplen; ++i) {
if (isDeleted(i))
continue;
}
+void Paragraph::anonymize()
+{
+ // This is a very crude anonymization for now
+ for (char_type & c : d->text_)
+ if (isLetterChar(c) || isNumber(c))
+ c = 'a';
+}
+
+
void Paragraph::Private::markMisspelledWords(
pos_type const & first, pos_type const & last,
SpellChecker::Result result,