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 "OutputParams.h"
31 #include "Paragraph.h"
32 #include "ParIterator.h"
33 #include "texstream.h"
36 #include "frontends/FontMetrics.h"
37 #include "frontends/Painter.h"
39 #include "support/debug.h"
40 #include "support/docstring.h"
41 #include "support/docstream.h"
42 #include "support/gettext.h"
43 #include "support/lstrings.h"
44 #include "support/textutils.h"
49 using namespace lyx::support;
55 /* codes used to read/write quotes to LyX files
57 * e ``english'' (`inner quotation')
58 * s ''swedish'' ('inner quotation')
59 * g ,,german`` (,inner quotation`)
60 * p ,,polish'' (,inner quotation')
61 * c <<swiss>> (<inner quotation>)
62 * a >>danish<< (>inner quotation<)
63 * q "plain" ('inner quotation')
64 * b `british' (``inner quotation'')
65 * w >>swedishg>> ('inner quotation') ["g" = Guillemets]
66 * f <<french>> (``inner quotation'')
67 * i <<frenchin>> (<<inner quotation>>) ["in" = Imprimerie Nationale]
68 * r <<russian>> (,,inner quotation``)
69 * j [U+300C]cjk[U+300D] ([U+300E]inner quotation[U+300F]) [CORNER BRACKETS]
70 * k [U+300A]cjkangle[U+300B] ([U+3008]inner quotation[U+3009]) [ANGLE BRACKETS]
71 * x dynamic style (inherits document settings)
74 char const * const style_char = "esgpcaqbwfirjkx";
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[style];
102 InsetQuotesParams::QuoteStyle InsetQuotesParams::getQuoteStyle(string const & s,
103 bool const allow_wildcards, QuoteStyle fb)
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.");
134 InsetQuotesParams::QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
135 bool const allow_wildcards, QuoteSide fb)
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]) {
151 res = InsetQuotesParams::QuoteSide(i);
156 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
157 " bad side specification.");
166 InsetQuotesParams::QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
167 bool const allow_wildcards, QuoteLevel fb)
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]) {
183 res = InsetQuotesParams::QuoteLevel(i);
188 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
189 " bad level specification.");
190 res = InsetQuotesParams::PrimaryQuotes;
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 EnglishQuotes: {
212 left_primary = 0x201c; // ``
213 right_primary = 0x201d; // ''
214 left_secondary = 0x2018; // `
215 right_secondary = 0x2019; // '
218 case SwedishQuotes: {
219 left_primary = 0x201d; // ''
220 right_primary = 0x201d; // ''
221 left_secondary = 0x2019; // '
222 right_secondary = 0x2019; // '
226 left_primary = 0x201e; // ,,
227 right_primary = 0x201c; // ``
228 left_secondary = 0x201a; // ,
229 right_secondary = 0x2018; // `
233 left_primary = 0x201e; // ,,
234 right_primary = 0x201d; // ''
235 left_secondary = 0x201a; // ,
236 right_secondary = 0x2019; // '
240 left_primary = 0x00ab; // <<
241 right_primary = 0x00bb; // >>
242 left_secondary = 0x2039; // <
243 right_secondary = 0x203a; // >
247 left_primary = 0x00bb; // >>
248 right_primary = 0x00ab; // <<
249 left_secondary = 0x203a; // >
250 right_secondary = 0x2039; // <
254 left_primary = 0x0022; // "
255 right_primary = 0x0022; // "
256 left_secondary = 0x0027; // '
257 right_secondary = 0x0027; // '
260 case BritishQuotes: {
261 left_primary = 0x2018; // `
262 right_primary = 0x2019; // '
263 left_secondary = 0x201c; // ``
264 right_secondary = 0x201d; // ''
267 case SwedishGQuotes: {
268 left_primary = 0x00bb; // >>
269 right_primary = 0x00bb; // >>
270 left_secondary = 0x2019; // '
271 right_secondary = 0x2019; // '
275 left_primary = 0x00ab; // <<
276 right_primary = 0x00bb; // >>
277 left_secondary = 0x201c; // ``
278 right_secondary = 0x201d; // ''
281 case FrenchINQuotes:{
282 left_primary = 0x00ab; // <<
283 right_primary = 0x00bb; // >>
284 left_secondary = 0x00ab; // <<
285 right_secondary = 0x00bb; // >>
289 left_primary = 0x00ab; // <<
290 right_primary = 0x00bb; // >>
291 left_secondary = 0x201e; // ,,
292 right_secondary = 0x201c; // ``
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 CJKAngleQuotes:{
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
312 left_primary = 0x003f; // ?
313 right_primary = 0x003f; // ?
314 left_secondary = 0x003f; // ?
315 right_secondary = 0x003f; // ?
320 case SecondaryQuotes:
322 return (side == ClosingQuote) ? left_secondary : right_secondary;
323 return (side == OpeningQuote) ? left_secondary : right_secondary;
326 return (side == ClosingQuote) ? left_primary : right_primary;
327 return (side == OpeningQuote) ? left_primary : right_primary;
337 docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op,
338 bool const rtl) const
347 res = "\\quotesinglbase";
352 // This macro is redefined in rtl mode
353 res = rtl ? "\\textquoteleft" : "\\textquoteright";
360 // This macro is redefined in rtl mode
361 res = rtl ? "\\textquoteright" : "\\textquoteleft";
370 res = "\\guilsinglleft";
377 res = "\\guilsinglright";
380 case 0x0027: {// ' (plain)
381 res = "\\textquotesingle";
387 else if (op == "babel")
390 res = "\\quotedblbase";
395 // This macro is redefined in rtl mode
396 res = rtl ? "\\textquotedblleft" : "\\textquotedblright";
403 // This macro is redefined in rtl mode
404 res = rtl ? "\\textquotedblright" : "\\textquotedblleft";
412 else if (op == "babel")
415 res = "\\guillemotleft";
421 else if (op == "babel")
424 res = "\\guillemotright";
428 res = "\\textquotedbl";
431 // The following are fakes
432 // This is just to get something symbolic
433 // in encodings where this chars would not be used anyway
434 case 0x300c: // LEFT CORNER BRACKET
435 res = "\\ensuremath{\\lceil}";
437 case 0x300d: // RIGHT CORNER BRACKET
438 res = "\\ensuremath{\\rfloor}";
440 case 0x300e: // LEFT WHITE CORNER BRACKET
441 res = "\\ensuremath{\\llceil}";
443 case 0x300f: // RIGHT WHITE CORNER BRACKET
444 res = "\\ensuremath{\\rrfloor}";
446 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
447 res = "\\ensuremath{\\langle\\kern-2.5pt\\langle}";
449 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
450 res = "\\ensuremath{\\rangle\\kern-2.5pt\\rangle}";
452 case 0x3008: // LEFT ANGLE BRACKET
453 res = "\\ensuremath{\\langle}";
455 case 0x3009: // RIGHT ANGLE BRACKET
456 res = "\\ensuremath{\\rangle}";
462 return from_ascii(res);
466 docstring InsetQuotesParams::getHTMLQuote(char_type c) const
486 case 0x0027: // ' (plain)
507 case 0x300c: // LEFT CORNER BRACKET
510 case 0x300d: // RIGHT CORNER BRACKET
513 case 0x300e: // LEFT WHITE CORNER BRACKET
516 case 0x300f: // RIGHT WHITE CORNER BRACKET
519 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
522 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
525 case 0x3008: // LEFT ANGLE BRACKET
528 case 0x3009: // RIGHT ANGLE BRACKET
535 return from_ascii(res);
539 docstring InsetQuotesParams::getXMLQuote(char_type c) const
541 // Directly output the character Unicode form.
542 return from_ascii("&#" + to_string(c) + ";");
546 map<string, docstring> InsetQuotesParams::getTypes() const
548 map<string, docstring> res;
556 // get all quote types
557 for (sty = 0; sty < stylescount(); ++sty) {
558 style = QuoteStyle(sty);
559 if (style == DynamicQuotes)
561 for (sid = 0; sid < 2; ++sid) {
562 side = QuoteSide(sid);
563 for (lev = 0; lev < 2; ++lev) {
564 type += style_char[style];
565 type += side_char[sid];
566 level = QuoteLevel(lev);
567 type += level_char[lev];
568 res[type] = docstring(1, getQuoteChar(style, level, side));
577 docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langdef)
579 docstring const styledesc =
580 bformat(_("%1$souter%2$s and %3$sinner%4$s[[quotation marks]]"),
581 docstring(1, getQuoteChar(qs, PrimaryQuotes, OpeningQuote)),
582 docstring(1, getQuoteChar(qs, PrimaryQuotes, ClosingQuote)),
583 docstring(1, getQuoteChar(qs, SecondaryQuotes, OpeningQuote)),
584 docstring(1, getQuoteChar(qs, SecondaryQuotes, ClosingQuote))
590 return bformat(_("%1$s[[quot. mark description]] (language default)"),
595 docstring const InsetQuotesParams::getShortGuiLabel(docstring const & str)
597 string const s = to_ascii(str);
598 QuoteStyle const style = getQuoteStyle(s);
599 QuoteSide const side = getQuoteSide(s);
600 QuoteLevel const level = getQuoteLevel(s);
602 return (side == OpeningQuote) ?
603 bformat(_("%1$stext"),
604 docstring(1, getQuoteChar(style, level, side))) :
605 bformat(_("text%1$s"),
606 docstring(1, getQuoteChar(style, level, side)));
610 /////////////////////////////////////////////////////////////////////
614 ///////////////////////////////////////////////////////////////////////
616 InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
618 style_(InsetQuotesParams::EnglishQuotes), side_(InsetQuotesParams::OpeningQuote),
619 pass_thru_(false), internal_fontenc_(false), rtl_(false)
622 global_style_ = buf->masterBuffer()->params().quotes_style;
623 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
626 global_style_ = InsetQuotesParams::EnglishQuotes;
634 InsetQuotes::InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
635 string const & side, string const & style)
636 : Inset(buf), level_(level), pass_thru_(false), fontspec_(false),
637 internal_fontenc_(false), rtl_(false)
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;
646 global_style_ = InsetQuotesParams::EnglishQuotes;
651 style_ = dynamic ? InsetQuotesParams::DynamicQuotes : global_style_;
653 style_ = getStyle(style);
655 if (side == "left" || side == "opening")
656 side_ = InsetQuotesParams::OpeningQuote;
657 else if (side == "right" || side == "closing")
658 side_ = InsetQuotesParams::ClosingQuote;
664 docstring InsetQuotes::layoutName() const
666 return from_ascii("Quotes");
670 void InsetQuotes::setSide(char_type c)
672 // Decide whether opening or closing quote
673 if (lyx::isSpace(c) || isOpenPunctuation(c))
674 side_ = InsetQuotesParams::OpeningQuote;// opening quote
676 side_ = InsetQuotesParams::ClosingQuote;// closing quote
680 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
682 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
683 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
684 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
688 InsetQuotesParams::QuoteStyle InsetQuotes::getStyle(string const & s)
690 InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::EnglishQuotes;
693 qs = InsetQuotesParams::EnglishQuotes;
694 else if (s == "swedish")
695 qs = InsetQuotesParams::SwedishQuotes;
696 else if (s == "german")
697 qs = InsetQuotesParams::GermanQuotes;
698 else if (s == "polish")
699 qs = InsetQuotesParams::PolishQuotes;
700 else if (s == "swiss")
701 qs = InsetQuotesParams::SwissQuotes;
702 else if (s == "danish")
703 qs = InsetQuotesParams::DanishQuotes;
704 else if (s == "plain")
705 qs = InsetQuotesParams::PlainQuotes;
706 else if (s == "british")
707 qs = InsetQuotesParams::BritishQuotes;
708 else if (s == "swedishg")
709 qs = InsetQuotesParams::SwedishGQuotes;
710 else if (s == "french")
711 qs = InsetQuotesParams::FrenchQuotes;
712 else if (s == "frenchin")
713 qs = InsetQuotesParams::FrenchINQuotes;
714 else if (s == "russian")
715 qs = InsetQuotesParams::RussianQuotes;
717 qs = InsetQuotesParams::CJKQuotes;
718 else if (s == "cjkangle")
719 qs = InsetQuotesParams::CJKAngleQuotes;
720 else if (s == "dynamic")
721 qs = InsetQuotesParams::DynamicQuotes;
727 docstring InsetQuotes::displayString() const
729 // In PassThru, we use straight quotes
731 return (level_ == InsetQuotesParams::PrimaryQuotes) ?
732 from_ascii("\"") : from_ascii("'");
734 InsetQuotesParams::QuoteStyle style =
735 (style_ == InsetQuotesParams::DynamicQuotes) ? 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_ == InsetQuotesParams::PrimaryQuotes
742 && (style == InsetQuotesParams::SwissQuotes
743 || style == InsetQuotesParams::FrenchQuotes
744 || style == InsetQuotesParams::FrenchINQuotes)) {
745 // THIN SPACE (U+2009)
746 char_type const thin_space = 0x2009;
747 if (side_ == InsetQuotesParams::OpeningQuote)
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_ == InsetQuotesParams::DynamicQuotes)
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[style_];
782 text += side_char[side_];
783 text += level_char[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
851 InsetQuotesParams::QuoteStyle style =
852 (style_ == InsetQuotesParams::DynamicQuotes) ? 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_ == InsetQuotesParams::PrimaryQuotes) ? from_ascii("\"") : from_ascii("'");
859 else if (style == InsetQuotesParams::PlainQuotes && 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_ == InsetQuotesParams::PrimaryQuotes) ?
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 == InsetQuotesParams::CJKQuotes || style == InsetQuotesParams::CJKAngleQuotes) {
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 == InsetQuotesParams::SwissQuotes
880 || style == InsetQuotesParams::FrenchQuotes
881 || style == InsetQuotesParams::FrenchINQuotes)
882 && level_ == InsetQuotesParams::PrimaryQuotes
883 && prefixIs(runparams.local_font->language()->code(), "fr")) {
884 // Specific guillemets of French babel
885 // including correct French spacing
886 if (side_ == InsetQuotesParams::OpeningQuote)
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 == OutputParams::LUATEX
926 || runparams.flavor == OutputParams::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 {
957 InsetQuotesParams::QuoteStyle style =
958 (style_ == InsetQuotesParams::DynamicQuotes) ? 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_ == InsetQuotesParams::PrimaryQuotes
965 && (style == InsetQuotesParams::FrenchQuotes
966 || style == InsetQuotesParams::FrenchINQuotes
967 || style == InsetQuotesParams::SwissQuotes)) {
968 // THIN SPACE (U+2009)
969 docstring const thin_space = from_ascii(" ");
970 if (side_ == InsetQuotesParams::OpeningQuote) // 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
1020 InsetQuotesParams::QuoteStyle style =
1021 (style_ == InsetQuotesParams::DynamicQuotes) ? 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";