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 dynamic = buf->masterBuffer()->params().dynamic_quotes;
643 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
646 style_ = dynamic ? QuoteStyle::Dynamic : global_style_;
648 style_ = getStyle(style);
650 if (side == "left" || side == "opening")
651 side_ = QuoteSide::Opening;
652 else if (side == "right" || side == "closing")
653 side_ = QuoteSide::Closing;
659 docstring InsetQuotes::layoutName() const
661 return from_ascii("Quotes");
665 void InsetQuotes::setSide(char_type c)
667 // Decide whether opening or closing quote
668 if (lyx::isSpace(c) || isOpenPunctuation(c))
669 side_ = QuoteSide::Opening;// opening quote
671 side_ = QuoteSide::Closing;// closing quote
675 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
677 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
678 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
679 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
683 QuoteStyle InsetQuotes::getStyle(string const & s)
685 QuoteStyle qs = QuoteStyle::English;
688 qs = QuoteStyle::English;
689 else if (s == "swedish")
690 qs = QuoteStyle::Swedish;
691 else if (s == "german")
692 qs = QuoteStyle::German;
693 else if (s == "polish")
694 qs = QuoteStyle::Polish;
695 else if (s == "swiss")
696 qs = QuoteStyle::Swiss;
697 else if (s == "danish")
698 qs = QuoteStyle::Danish;
699 else if (s == "plain")
700 qs = QuoteStyle::Plain;
701 else if (s == "british")
702 qs = QuoteStyle::British;
703 else if (s == "swedishg")
704 qs = QuoteStyle::SwedishG;
705 else if (s == "french")
706 qs = QuoteStyle::French;
707 else if (s == "frenchin")
708 qs = QuoteStyle::FrenchIN;
709 else if (s == "russian")
710 qs = QuoteStyle::Russian;
712 qs = QuoteStyle::CJK;
713 else if (s == "cjkangle")
714 qs = QuoteStyle::CJKAngle;
715 else if (s == "hungarian")
716 qs = QuoteStyle::Hungarian;
717 else if (s == "dynamic")
718 qs = QuoteStyle::Dynamic;
724 docstring InsetQuotes::displayString() const
726 // In PassThru, we use straight quotes
728 return (level_ == QuoteLevel::Primary) ?
729 from_ascii("\"") : from_ascii("'");
732 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
734 docstring retdisp = docstring(1, quoteparams.getQuoteChar(style, level_, side_, rtl_));
736 // in French, thin spaces are added inside double guillemets
737 if (prefixIs(context_lang_, "fr")
738 && level_ == QuoteLevel::Primary
739 && (style == QuoteStyle::Swiss
740 || style == QuoteStyle::French
741 || style == QuoteStyle::FrenchIN)) {
742 // THIN SPACE (U+2009)
743 char_type const thin_space = 0x2009;
744 if (side_ == QuoteSide::Opening)
745 retdisp += thin_space;
747 retdisp = thin_space + retdisp;
754 void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
756 FontInfo & font = mi.base.font;
757 frontend::FontMetrics const & fm = theFontMetrics(font);
758 dim.asc = fm.maxAscent();
759 dim.des = fm.maxDescent();
760 dim.wid = fm.width(displayString());
764 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
766 FontInfo font = pi.base.font;
767 if (style_ == QuoteStyle::Dynamic)
768 font.setPaintColor(Color_special);
770 font.setPaintColor(pi.textColor(font.realColor()));
771 pi.pain.text(x, y, displayString(), font);
775 string InsetQuotes::getType() const
778 text += style_char[static_cast<int>(style_)];
779 text += side_char[static_cast<int>(side_)];
780 text += level_char[static_cast<int>(level_)];
785 void InsetQuotes::write(ostream & os) const
787 os << "Quotes " << getType();
791 void InsetQuotes::read(Lexer & lex)
793 lex.setContext("InsetQuotes::read");
795 parseString(lex.getString());
796 lex >> "\\end_inset";
800 void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
802 switch (cmd.action()) {
803 case LFUN_INSET_MODIFY: {
804 string const first_arg = cmd.getArg(0);
805 bool const change_type = first_arg == "changetype";
808 // this will not be handled higher up
812 cur.recordUndoInset(this);
813 parseString(cmd.getArg(1), true);
814 cur.forceBufferUpdate();
818 Inset::doDispatch(cur, cmd);
824 bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd,
825 FuncStatus & flag) const
827 switch (cmd.action()) {
829 case LFUN_INSET_MODIFY: {
830 string const first_arg = cmd.getArg(0);
831 if (first_arg == "changetype") {
832 string const type = cmd.getArg(1);
833 flag.setOnOff(type == getType());
834 flag.setEnabled(!pass_thru_);
837 return Inset::getStatus(cur, cmd, flag);
841 return Inset::getStatus(cur, cmd, flag);
846 void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
849 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
850 char_type quotechar = quoteparams.getQuoteChar(style, level_, side_, rtl_);
853 // In pass-thru context, we output plain quotes
854 if (runparams.pass_thru || runparams.find_effective())
855 qstr = (level_ == QuoteLevel::Primary) ? from_ascii("\"") : from_ascii("'");
856 else if (style == QuoteStyle::Plain && fontspec_) {
857 // For XeTeX and LuaTeX,we need to disable mapping to get straight
858 // quotes. We define our own commands that do this
859 qstr = (level_ == QuoteLevel::Primary) ?
860 from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
862 else if (runparams.use_polyglossia) {
863 // For polyglossia, we directly output the respective unicode chars
864 // (spacing and kerning is then handled respectively)
865 qstr = docstring(1, quotechar);
867 // The CJK marks are not yet covered by utf8 inputenc (we don't have the entry in
868 // unicodesymbols, since we don't want to add fake synbols there).
869 else if (style == QuoteStyle::CJK || style == QuoteStyle::CJKAngle) {
870 if (runparams.encoding && runparams.encoding->name() != "utf8"
871 && runparams.encoding->encodable(quotechar))
872 qstr = docstring(1, quotechar);
874 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
876 else if ((style == QuoteStyle::Swiss
877 || style == QuoteStyle::French
878 || style == QuoteStyle::FrenchIN)
879 && level_ == QuoteLevel::Primary
880 && prefixIs(runparams.local_font->language()->code(), "fr")) {
881 // Specific guillemets of French babel
882 // including correct French spacing
883 if (side_ == QuoteSide::Opening)
884 qstr = from_ascii("\\og");
886 qstr = from_ascii("\\fg");
887 } else if (runparams.use_hyperref && runparams.moving_arg) {
888 // Use internal commands in headings with hyperref
889 // (ligatures not featured in PDF strings)
890 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
891 } else if (runparams.main_fontenc == "T1"
892 && !runparams.local_font->language()->internalFontEncoding()) {
893 // Quotation marks for T1 font encoding
895 qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
896 } else if (runparams.local_font->language()->internalFontEncoding()) {
897 // Quotation marks for internal font encodings
898 // (ligatures not featured)
899 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
900 #ifdef DO_USE_DEFAULT_LANGUAGE
901 } else if ((doclang == "default"
903 } else if ((!runparams.use_babel
905 || (runparams.main_fontenc != "T1" && runparams.main_fontenc != "OT1"))
906 || runparams.isFullUnicode()) {
907 // Standard quotation mark macros
908 // These are also used by babel
909 // without fontenc (XeTeX/LuaTeX)
910 qstr = quoteparams.getLaTeXQuote(quotechar, "ot1");
912 // Babel shorthand quotation marks (for T1/OT1)
913 qstr = quoteparams.getLaTeXQuote(quotechar, "babel");
916 if (!runparams.pass_thru) {
917 // Guard against unwanted ligatures with preceding text
918 char_type const lastchar = os.lastChar();
919 // LuaTeX does not respect {} as ligature breaker by design,
920 // see https://tex.stackexchange.com/q/349725/19291
921 docstring const nolig =
922 (runparams.flavor == Flavor::LuaTeX
923 || runparams.flavor == Flavor::DviLuaTeX) ?
924 from_ascii("\\/") : from_ascii("{}");
925 // !` ?` => !{}` ?{}`
926 if (prefixIs(qstr, from_ascii("`"))
927 && (lastchar == '!' || lastchar == '?'))
929 // ``` ''' ,,, <<< >>>
930 // => `{}`` '{}'' ,{},, <{}<< >{}>>
931 if (contains(from_ascii(",'`<>"), lastchar)
932 && prefixIs(qstr, lastchar))
938 if (prefixIs(qstr, from_ascii("\\")) && !suffixIs(qstr, '}'))
939 // properly terminate the command depending on the context
944 int InsetQuotes::plaintext(odocstringstream & os,
945 OutputParams const & op, size_t) const
947 if (!op.find_effective()) {
948 docstring const str = displayString();
953 if (level_ == QuoteLevel::Primary)
954 os << from_ascii("\"");
956 os << from_ascii("'");
962 docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
964 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
965 docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) :
966 quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_));
968 // in French, thin spaces are added inside double guillemets
969 if (prefixIs(context_lang_, "fr")
970 && level_ == QuoteLevel::Primary
971 && (style == QuoteStyle::French
972 || style == QuoteStyle::FrenchIN
973 || style == QuoteStyle::Swiss)) {
974 // THIN SPACE (U+2009)
975 docstring const thin_space = from_ascii(" ");
976 if (side_ == QuoteSide::Opening) // Open quote: space after
978 else // Close quote: space before
979 res = thin_space + res;
985 void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const
987 xs << XMLStream::ESCAPE_NONE << getQuoteEntity(false);
991 docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
993 xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true);
998 void InsetQuotes::toString(odocstream & os) const
1000 os << displayString();
1004 void InsetQuotes::forOutliner(docstring & os, size_t const, bool const) const
1006 os += displayString();
1010 void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/, bool const /*deleted*/)
1012 BufferParams const & bp = buffer().masterBuffer()->params();
1013 Font const & font = it.paragraph().getFontSettings(bp, it.pos());
1014 pass_thru_ = it.paragraph().isPassThru();
1015 context_lang_ = font.language()->code();
1016 internal_fontenc_ = font.language()->internalFontEncoding();
1017 global_style_ = bp.quotes_style;
1018 fontspec_ = bp.useNonTeXFonts;
1019 rtl_ = font.isRightToLeft();
1023 void InsetQuotes::validate(LaTeXFeatures & features) const
1026 (style_ == QuoteStyle::Dynamic) ? global_style_ : style_;
1027 char_type type = quoteparams.getQuoteChar(style, level_, side_);
1029 // Handle characters that are not natively supported by
1030 // specific font encodings (we roll our own definitions)
1031 #ifdef DO_USE_DEFAULT_LANGUAGE
1032 if (features.bufferParams().language->lang() == "default"
1034 if (!features.useBabel()
1036 && !features.runparams().isFullUnicode()
1037 && features.runparams().main_fontenc != "T1") {
1040 features.require("quotesinglbase");
1043 features.require("guilsinglleft");
1046 features.require("guilsinglright");
1049 features.require("quotedblbase");
1052 features.require("guillemotleft");
1055 features.require("guillemotright");
1061 // Handle straight quotation marks. These need special care
1062 // in most output formats
1065 if (features.runparams().isFullUnicode() && fontspec_)
1066 features.require("textquotesinglep");
1068 features.require("textcomp");
1072 if (features.runparams().isFullUnicode() && fontspec_)
1073 features.require("textquotedblp");
1074 else if (features.runparams().main_fontenc != "T1" || internal_fontenc_)
1075 features.require("textquotedbl");
1078 // we fake these from math (also for utf8 inputenc
1079 // currently; see above)
1080 case 0x300e: // LEFT WHITE CORNER BRACKET
1081 case 0x300f: // RIGHT WHITE CORNER BRACKET
1082 if (!features.runparams().encoding
1083 || features.runparams().encoding->name() == "utf8"
1084 || !features.runparams().encoding->encodable(type))
1085 features.require("stmaryrd");
1093 string InsetQuotes::contextMenuName() const
1095 return "context-quote";