2 * \file InsetQuotes.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jean-Marc Lasgouttes
7 * \author Jürgen Spitzmüller
9 * Full author contact details are available in file CREDITS.
14 #include "InsetQuotes.h"
17 #include "BufferParams.h"
18 #include "BufferView.h"
20 #include "Dimension.h"
23 #include "FuncStatus.h"
24 #include "FuncRequest.h"
26 #include "LaTeXFeatures.h"
29 #include "MetricsInfo.h"
30 #include "Paragraph.h"
31 #include "ParIterator.h"
32 #include "texstream.h"
35 #include "frontends/FontMetrics.h"
36 #include "frontends/Painter.h"
38 #include "support/debug.h"
39 #include "support/docstring.h"
40 #include "support/docstream.h"
41 #include "support/gettext.h"
42 #include "support/lstrings.h"
43 #include "support/textutils.h"
48 using namespace lyx::support;
54 /* codes used to read/write quotes to LyX files
56 * e ``english'' (`inner quotation')
57 * s ''swedish'' ('inner quotation')
58 * g ,,german`` (,inner quotation`)
59 * p ,,polish'' (,inner quotation')
60 * c <<swiss>> (<inner quotation>)
61 * a >>danish<< (>inner quotation<)
62 * q "plain" ('inner quotation')
63 * b `british' (``inner quotation'')
64 * w >>swedishg>> ('inner quotation') ["g" = Guillemets]
65 * f <<french>> (``inner quotation'')
66 * i <<frenchin>> (<<inner quotation>>) ["in" = Imprimerie Nationale]
67 * r <<russian>> (,,inner quotation``)
68 * j [U+300C]cjk[U+300D] ([U+300E]inner quotation[U+300F]) [CORNER BRACKETS]
69 * k [U+300A]cjkangle[U+300B] ([U+3008]inner quotation[U+3009]) [ANGLE BRACKETS]
70 * h ,,hungarian'' (>>inner quotation<<)
71 * x dynamic style (inherits document settings)
74 char const * const style_char = "esgpcaqbwfirjkhx";
75 char const * const side_char = "lr" ;
76 char const * const level_char = "sd";
81 /////////////////////////////////////////////////////////////////////
85 ///////////////////////////////////////////////////////////////////////
87 InsetQuotesParams quoteparams;
90 int InsetQuotesParams::stylescount() const
92 return strlen(style_char);
96 char InsetQuotesParams::getStyleChar(QuoteStyle const & style) const
98 return style_char[static_cast<int>(style)];
102 QuoteStyle InsetQuotesParams::getQuoteStyle(string const & s,
103 bool const allow_wildcards, QuoteStyle fb) const
108 if (str.length() != 3) {
109 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
110 " bad string length.");
114 // '.' wildcard means: keep current style
115 if (!allow_wildcards || str[0] != '.') {
117 for (i = 0; i < stylescount(); ++i) {
118 if (str[0] == style_char[i]) {
123 if (i >= stylescount()) {
124 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
125 " bad style specification.");
126 res = QuoteStyle::English;
134 QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
135 bool const allow_wildcards, QuoteSide fb) const
140 if (str.length() != 3) {
141 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
142 " bad string length.");
146 // '.' wildcard means: keep current side
147 if (!allow_wildcards || str[1] != '.') {
149 for (i = 0; i < 2; ++i) {
150 if (str[1] == side_char[i]) {
156 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
157 " bad side specification.");
158 res = QuoteSide::Opening;
166 QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
167 bool const allow_wildcards, QuoteLevel fb) const
172 if (str.length() != 3) {
173 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
174 " bad string length.");
178 // '.' wildcard means: keep current level
179 if (!allow_wildcards || str[2] != '.') {
181 for (i = 0; i < 2; ++i) {
182 if (str[2] == level_char[i]) {
188 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
189 " bad level specification.");
190 res = QuoteLevel::Primary;
198 char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel const & level,
199 QuoteSide const & side, bool const rtl) const
201 // main opening quotation mark
202 char_type left_primary;
203 // main closing quotation mark
204 char_type right_primary;
205 // secondary (inner, 'single') opening quotation mark
206 char_type left_secondary;
207 // secondary (inner, 'single') closing quotation mark
208 char_type right_secondary;
211 case QuoteStyle::English: {
212 left_primary = 0x201c; // ``
213 right_primary = 0x201d; // ''
214 left_secondary = 0x2018; // `
215 right_secondary = 0x2019; // '
218 case QuoteStyle::Swedish: {
219 left_primary = 0x201d; // ''
220 right_primary = 0x201d; // ''
221 left_secondary = 0x2019; // '
222 right_secondary = 0x2019; // '
225 case QuoteStyle::German: {
226 left_primary = 0x201e; // ,,
227 right_primary = 0x201c; // ``
228 left_secondary = 0x201a; // ,
229 right_secondary = 0x2018; // `
232 case QuoteStyle::Polish: {
233 left_primary = 0x201e; // ,,
234 right_primary = 0x201d; // ''
235 left_secondary = 0x201a; // ,
236 right_secondary = 0x2019; // '
239 case QuoteStyle::Swiss: {
240 left_primary = 0x00ab; // <<
241 right_primary = 0x00bb; // >>
242 left_secondary = 0x2039; // <
243 right_secondary = 0x203a; // >
246 case QuoteStyle::Danish: {
247 left_primary = 0x00bb; // >>
248 right_primary = 0x00ab; // <<
249 left_secondary = 0x203a; // >
250 right_secondary = 0x2039; // <
253 case QuoteStyle::Plain: {
254 left_primary = 0x0022; // "
255 right_primary = 0x0022; // "
256 left_secondary = 0x0027; // '
257 right_secondary = 0x0027; // '
260 case QuoteStyle::British: {
261 left_primary = 0x2018; // `
262 right_primary = 0x2019; // '
263 left_secondary = 0x201c; // ``
264 right_secondary = 0x201d; // ''
267 case QuoteStyle::SwedishG: {
268 left_primary = 0x00bb; // >>
269 right_primary = 0x00bb; // >>
270 left_secondary = 0x2019; // '
271 right_secondary = 0x2019; // '
274 case QuoteStyle::French: {
275 left_primary = 0x00ab; // <<
276 right_primary = 0x00bb; // >>
277 left_secondary = 0x201c; // ``
278 right_secondary = 0x201d; // ''
281 case QuoteStyle::FrenchIN:{
282 left_primary = 0x00ab; // <<
283 right_primary = 0x00bb; // >>
284 left_secondary = 0x00ab; // <<
285 right_secondary = 0x00bb; // >>
288 case QuoteStyle::Russian:{
289 left_primary = 0x00ab; // <<
290 right_primary = 0x00bb; // >>
291 left_secondary = 0x201e; // ,,
292 right_secondary = 0x201c; // ``
295 case QuoteStyle::CJK:{
296 left_primary = 0x300c; // LEFT CORNER BRACKET
297 right_primary = 0x300d; // RIGHT CORNER BRACKET
298 left_secondary = 0x300e; // LEFT WHITE CORNER BRACKET
299 right_secondary = 0x300f; // RIGHT WHITE CORNER BRACKET
302 case QuoteStyle::CJKAngle:{
303 left_primary = 0x300a; // LEFT DOUBLE ANGLE BRACKET
304 right_primary = 0x300b; // RIGHT DOUBLE ANGLE BRACKET
305 left_secondary = 0x3008; // LEFT ANGLE BRACKET
306 right_secondary = 0x3009; // RIGHT ANGLE BRACKET
309 case QuoteStyle::Hungarian: {
310 left_primary = 0x201e; // ,,
311 right_primary = 0x201d; // ''
312 left_secondary = 0x00bb; // >>
313 right_secondary = 0x00ab; // <<
316 case QuoteStyle::Dynamic:
319 left_primary = 0x003f; // ?
320 right_primary = 0x003f; // ?
321 left_secondary = 0x003f; // ?
322 right_secondary = 0x003f; // ?
327 case QuoteLevel::Secondary:
329 return (side == QuoteSide::Closing) ? left_secondary : right_secondary;
330 return (side == QuoteSide::Opening) ? left_secondary : right_secondary;
331 case QuoteLevel::Primary:
333 return (side == QuoteSide::Closing) ? left_primary : right_primary;
334 return (side == QuoteSide::Opening) ? left_primary : right_primary;
344 docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op,
345 bool const rtl) const
354 res = "\\quotesinglbase";
359 // This macro is redefined in rtl mode
360 res = rtl ? "\\textquoteleft" : "\\textquoteright";
367 // This macro is redefined in rtl mode
368 res = rtl ? "\\textquoteright" : "\\textquoteleft";
377 res = "\\guilsinglleft";
384 res = "\\guilsinglright";
387 case 0x0027: {// ' (plain)
388 res = "\\textquotesingle";
394 else if (op == "babel")
397 res = "\\quotedblbase";
402 // This macro is redefined in rtl mode
403 res = rtl ? "\\textquotedblleft" : "\\textquotedblright";
410 // This macro is redefined in rtl mode
411 res = rtl ? "\\textquotedblright" : "\\textquotedblleft";
419 else if (op == "babel")
422 res = "\\guillemotleft";
428 else if (op == "babel")
431 res = "\\guillemotright";
435 res = "\\textquotedbl";
438 // The following are fakes
439 // This is just to get something symbolic
440 // in encodings where this chars would not be used anyway
441 case 0x300c: // LEFT CORNER BRACKET
442 res = "\\ensuremath{\\lceil}";
444 case 0x300d: // RIGHT CORNER BRACKET
445 res = "\\ensuremath{\\rfloor}";
447 case 0x300e: // LEFT WHITE CORNER BRACKET
448 res = "\\ensuremath{\\llceil}";
450 case 0x300f: // RIGHT WHITE CORNER BRACKET
451 res = "\\ensuremath{\\rrfloor}";
453 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
454 res = "\\ensuremath{\\langle\\kern-2.5pt\\langle}";
456 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
457 res = "\\ensuremath{\\rangle\\kern-2.5pt\\rangle}";
459 case 0x3008: // LEFT ANGLE BRACKET
460 res = "\\ensuremath{\\langle}";
462 case 0x3009: // RIGHT ANGLE BRACKET
463 res = "\\ensuremath{\\rangle}";
469 return from_ascii(res);
473 docstring InsetQuotesParams::getHTMLQuote(char_type c) const
493 case 0x0027: // ' (plain)
514 case 0x300c: // LEFT CORNER BRACKET
517 case 0x300d: // RIGHT CORNER BRACKET
520 case 0x300e: // LEFT WHITE CORNER BRACKET
523 case 0x300f: // RIGHT WHITE CORNER BRACKET
526 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
529 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
532 case 0x3008: // LEFT ANGLE BRACKET
535 case 0x3009: // RIGHT ANGLE BRACKET
542 return from_ascii(res);
546 docstring InsetQuotesParams::getXMLQuote(char_type c) const
548 // Directly output the character Unicode form.
549 return from_ascii("&#" + to_string(c) + ";");
553 map<string, docstring> InsetQuotesParams::getTypes() const
555 map<string, docstring> res;
563 // get all quote types
564 for (sty = 0; sty < stylescount(); ++sty) {
565 style = QuoteStyle(sty);
566 if (style == QuoteStyle::Dynamic)
568 for (sid = 0; sid < 2; ++sid) {
569 side = QuoteSide(sid);
570 for (lev = 0; lev < 2; ++lev) {
571 type += style_char[static_cast<int>(style)];
572 type += side_char[sid];
573 level = QuoteLevel(lev);
574 type += level_char[lev];
575 res[type] = docstring(1, getQuoteChar(style, level, side));
584 docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langdef) const
586 docstring const styledesc =
587 bformat(_("%1$souter%2$s and %3$sinner%4$s[[quotation marks]]"),
588 docstring(1, getQuoteChar(qs, QuoteLevel::Primary, QuoteSide::Opening)),
589 docstring(1, getQuoteChar(qs, QuoteLevel::Primary, QuoteSide::Closing)),
590 docstring(1, getQuoteChar(qs, QuoteLevel::Secondary, QuoteSide::Opening)),
591 docstring(1, getQuoteChar(qs, QuoteLevel::Secondary, QuoteSide::Closing))
597 return bformat(_("%1$s[[quot. mark description]] (language default)"),
602 docstring const InsetQuotesParams::getShortGuiLabel(docstring const & str) const
604 string const s = to_ascii(str);
605 QuoteStyle const style = getQuoteStyle(s);
606 QuoteSide const side = getQuoteSide(s);
607 QuoteLevel const level = getQuoteLevel(s);
609 return (side == QuoteSide::Opening) ?
610 bformat(_("%1$stext"),
611 docstring(1, getQuoteChar(style, level, side))) :
612 bformat(_("text%1$s"),
613 docstring(1, getQuoteChar(style, level, side)));
617 /////////////////////////////////////////////////////////////////////
621 ///////////////////////////////////////////////////////////////////////
623 InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
627 global_style_ = buf->masterBuffer()->params().quotes_style;
628 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
635 InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteLevel level,
636 string const & side, string const & style)
637 : Inset(buf), level_(level)
639 bool dynamic = false;
641 global_style_ = buf->masterBuffer()->params().quotes_style;
642 fontenc_ = buf->masterBuffer()->params().main_font_encoding();
643 dynamic = buf->masterBuffer()->params().dynamic_quotes;
644 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
649 style_ = dynamic ? QuoteStyle::Dynamic : global_style_;
651 style_ = getStyle(style);
653 if (side == "left" || side == "opening")
654 side_ = QuoteSide::Opening;
655 else if (side == "right" || side == "closing")
656 side_ = QuoteSide::Closing;
662 docstring InsetQuotes::layoutName() const
664 return from_ascii("Quotes");
668 void InsetQuotes::setSide(char_type c)
670 // Decide whether opening or closing quote
671 if (lyx::isSpace(c) || isOpenPunctuation(c))
672 side_ = QuoteSide::Opening;// opening quote
674 side_ = QuoteSide::Closing;// closing quote
678 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
680 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
681 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
682 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
686 QuoteStyle InsetQuotes::getStyle(string const & s)
688 QuoteStyle qs = QuoteStyle::English;
691 qs = QuoteStyle::English;
692 else if (s == "swedish")
693 qs = QuoteStyle::Swedish;
694 else if (s == "german")
695 qs = QuoteStyle::German;
696 else if (s == "polish")
697 qs = QuoteStyle::Polish;
698 else if (s == "swiss")
699 qs = QuoteStyle::Swiss;
700 else if (s == "danish")
701 qs = QuoteStyle::Danish;
702 else if (s == "plain")
703 qs = QuoteStyle::Plain;
704 else if (s == "british")
705 qs = QuoteStyle::British;
706 else if (s == "swedishg")
707 qs = QuoteStyle::SwedishG;
708 else if (s == "french")
709 qs = QuoteStyle::French;
710 else if (s == "frenchin")
711 qs = QuoteStyle::FrenchIN;
712 else if (s == "russian")
713 qs = QuoteStyle::Russian;
715 qs = QuoteStyle::CJK;
716 else if (s == "cjkangle")
717 qs = QuoteStyle::CJKAngle;
718 else if (s == "hungarian")
719 qs = QuoteStyle::Hungarian;
720 else if (s == "dynamic")
721 qs = QuoteStyle::Dynamic;
727 docstring InsetQuotes::displayString() const
729 // In PassThru, we use straight quotes
731 return (level_ == QuoteLevel::Primary) ?
732 from_ascii("\"") : from_ascii("'");
735 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
737 docstring retdisp = docstring(1, quoteparams.getQuoteChar(style, level_, side_, rtl_));
739 // in French, thin spaces are added inside double guillemets
740 if (prefixIs(context_lang_, "fr")
741 && level_ == QuoteLevel::Primary
742 && (style == QuoteStyle::Swiss
743 || style == QuoteStyle::French
744 || style == QuoteStyle::FrenchIN)) {
745 // THIN SPACE (U+2009)
746 char_type const thin_space = 0x2009;
747 if (side_ == QuoteSide::Opening)
748 retdisp += thin_space;
750 retdisp = thin_space + retdisp;
757 void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
759 FontInfo & font = mi.base.font;
760 frontend::FontMetrics const & fm = theFontMetrics(font);
761 dim.asc = fm.maxAscent();
762 dim.des = fm.maxDescent();
763 dim.wid = fm.width(displayString());
767 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
769 FontInfo font = pi.base.font;
770 if (style_ == QuoteStyle::Dynamic)
771 font.setPaintColor(Color_special);
773 font.setPaintColor(pi.textColor(font.realColor()));
774 pi.pain.text(x, y, displayString(), font);
778 string InsetQuotes::getType() const
781 text += style_char[static_cast<int>(style_)];
782 text += side_char[static_cast<int>(side_)];
783 text += level_char[static_cast<int>(level_)];
788 void InsetQuotes::write(ostream & os) const
790 os << "Quotes " << getType();
794 void InsetQuotes::read(Lexer & lex)
796 lex.setContext("InsetQuotes::read");
798 parseString(lex.getString());
799 lex >> "\\end_inset";
803 void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
805 switch (cmd.action()) {
806 case LFUN_INSET_MODIFY: {
807 string const first_arg = cmd.getArg(0);
808 bool const change_type = first_arg == "changetype";
811 // this will not be handled higher up
815 cur.recordUndoInset(this);
816 parseString(cmd.getArg(1), true);
817 cur.forceBufferUpdate();
821 Inset::doDispatch(cur, cmd);
827 bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd,
828 FuncStatus & flag) const
830 switch (cmd.action()) {
832 case LFUN_INSET_MODIFY: {
833 string const first_arg = cmd.getArg(0);
834 if (first_arg == "changetype") {
835 string const type = cmd.getArg(1);
836 flag.setOnOff(type == getType());
837 flag.setEnabled(!pass_thru_);
840 return Inset::getStatus(cur, cmd, flag);
844 return Inset::getStatus(cur, cmd, flag);
849 void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
852 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
853 char_type quotechar = quoteparams.getQuoteChar(style, level_, side_, rtl_);
856 // In pass-thru context, we output plain quotes
857 if (runparams.pass_thru)
858 qstr = (level_ == QuoteLevel::Primary) ? from_ascii("\"") : from_ascii("'");
859 else if (style == QuoteStyle::Plain && fontspec_) {
860 // For XeTeX and LuaTeX,we need to disable mapping to get straight
861 // quotes. We define our own commands that do this
862 qstr = (level_ == QuoteLevel::Primary) ?
863 from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
865 else if (runparams.use_polyglossia) {
866 // For polyglossia, we directly output the respective unicode chars
867 // (spacing and kerning is then handled respectively)
868 qstr = docstring(1, quotechar);
870 // The CJK marks are not yet covered by utf8 inputenc (we don't have the entry in
871 // unicodesymbols, since we don't want to add fake synbols there).
872 else if (style == QuoteStyle::CJK || style == QuoteStyle::CJKAngle) {
873 if (runparams.encoding && runparams.encoding->name() != "utf8"
874 && runparams.encoding->encodable(quotechar))
875 qstr = docstring(1, quotechar);
877 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
879 else if ((style == QuoteStyle::Swiss
880 || style == QuoteStyle::French
881 || style == QuoteStyle::FrenchIN)
882 && level_ == QuoteLevel::Primary
883 && prefixIs(runparams.local_font->language()->code(), "fr")) {
884 // Specific guillemets of French babel
885 // including correct French spacing
886 if (side_ == QuoteSide::Opening)
887 qstr = from_ascii("\\og");
889 qstr = from_ascii("\\fg");
890 } else if (runparams.use_hyperref && runparams.moving_arg) {
891 // Use internal commands in headings with hyperref
892 // (ligatures not featured in PDF strings)
893 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
894 } else if (fontenc_ == "T1"
895 && !runparams.local_font->language()->internalFontEncoding()) {
896 // Quotation marks for T1 font encoding
898 qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
899 } else if (runparams.local_font->language()->internalFontEncoding()) {
900 // Quotation marks for internal font encodings
901 // (ligatures not featured)
902 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
903 #ifdef DO_USE_DEFAULT_LANGUAGE
904 } else if ((doclang == "default"
906 } else if ((!runparams.use_babel
908 || (fontenc_ != "T1" && fontenc_ != "OT1"))
909 || runparams.isFullUnicode()) {
910 // Standard quotation mark macros
911 // These are also used by babel
912 // without fontenc (XeTeX/LuaTeX)
913 qstr = quoteparams.getLaTeXQuote(quotechar, "ot1");
915 // Babel shorthand quotation marks (for T1/OT1)
916 qstr = quoteparams.getLaTeXQuote(quotechar, "babel");
919 if (!runparams.pass_thru) {
920 // Guard against unwanted ligatures with preceding text
921 char_type const lastchar = os.lastChar();
922 // LuaTeX does not respect {} as ligature breaker by design,
923 // see https://tex.stackexchange.com/q/349725/19291
924 docstring const nolig =
925 (runparams.flavor == Flavor::LuaTeX
926 || runparams.flavor == Flavor::DviLuaTeX) ?
927 from_ascii("\\/") : from_ascii("{}");
928 // !` ?` => !{}` ?{}`
929 if (prefixIs(qstr, from_ascii("`"))
930 && (lastchar == '!' || lastchar == '?'))
932 // ``` ''' ,,, <<< >>>
933 // => `{}`` '{}'' ,{},, <{}<< >{}>>
934 if (contains(from_ascii(",'`<>"), lastchar)
935 && prefixIs(qstr, lastchar))
941 if (prefixIs(qstr, from_ascii("\\")) && !suffixIs(qstr, '}'))
942 // properly terminate the command depending on the context
947 int InsetQuotes::plaintext(odocstringstream & os,
948 OutputParams const &, size_t) const
950 docstring const str = displayString();
956 docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
958 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
959 docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) :
960 quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
962 // in French, thin spaces are added inside double guillemets
963 if (prefixIs(context_lang_, "fr")
964 && level_ == QuoteLevel::Primary
965 && (style == QuoteStyle::French
966 || style == QuoteStyle::FrenchIN
967 || style == QuoteStyle::Swiss)) {
968 // THIN SPACE (U+2009)
969 docstring const thin_space = from_ascii(" ");
970 if (side_ == QuoteSide::Opening) // Open quote: space after
972 else // Close quote: space before
973 res = thin_space + res;
979 void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const
981 xs << XMLStream::ESCAPE_NONE << getQuoteEntity(false);
985 docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
987 xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true);
992 void InsetQuotes::toString(odocstream & os) const
994 os << displayString();
998 void InsetQuotes::forOutliner(docstring & os, size_t const, bool const) const
1000 os += displayString();
1004 void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/, bool const /*deleted*/)
1006 BufferParams const & bp = buffer().masterBuffer()->params();
1007 Font const & font = it.paragraph().getFontSettings(bp, it.pos());
1008 pass_thru_ = it.paragraph().isPassThru();
1009 context_lang_ = font.language()->code();
1010 internal_fontenc_ = font.language()->internalFontEncoding();
1011 fontenc_ = bp.main_font_encoding();
1012 global_style_ = bp.quotes_style;
1013 fontspec_ = bp.useNonTeXFonts;
1014 rtl_ = font.isRightToLeft();
1018 void InsetQuotes::validate(LaTeXFeatures & features) const
1021 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
1022 char_type type = quoteparams.getQuoteChar(style, level_, side_);
1024 // Handle characters that are not natively supported by
1025 // specific font encodings (we roll our own definitions)
1026 #ifdef DO_USE_DEFAULT_LANGUAGE
1027 if (features.bufferParams().language->lang() == "default"
1029 if (!features.useBabel()
1031 && !features.runparams().isFullUnicode() && fontenc_ != "T1") {
1034 features.require("quotesinglbase");
1037 features.require("guilsinglleft");
1040 features.require("guilsinglright");
1043 features.require("quotedblbase");
1046 features.require("guillemotleft");
1049 features.require("guillemotright");
1055 // Handle straight quotation marks. These need special care
1056 // in most output formats
1059 if (features.runparams().isFullUnicode() && fontspec_)
1060 features.require("textquotesinglep");
1062 features.require("textcomp");
1066 if (features.runparams().isFullUnicode() && fontspec_)
1067 features.require("textquotedblp");
1068 else if (fontenc_ != "T1" || internal_fontenc_)
1069 features.require("textquotedbl");
1072 // we fake these from math (also for utf8 inputenc
1073 // currently; see above)
1074 case 0x300e: // LEFT WHITE CORNER BRACKET
1075 case 0x300f: // RIGHT WHITE CORNER BRACKET
1076 if (!features.runparams().encoding
1077 || features.runparams().encoding->name() == "utf8"
1078 || !features.runparams().encoding->encodable(type))
1079 features.require("stmaryrd");
1087 string InsetQuotes::contextMenuName() const
1089 return "context-quote";