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 "output_xhtml.h"
32 #include "Paragraph.h"
33 #include "ParIterator.h"
34 #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.");
116 // '.' wildcard means: keep current style
117 if (!allow_wildcards || str[0] != '.') {
118 for (i = 0; i < stylescount(); ++i) {
119 if (str[0] == style_char[i]) {
124 if (i >= stylescount()) {
125 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
126 " bad style specification.");
135 InsetQuotesParams::QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
136 bool const allow_wildcards, QuoteSide fb)
141 if (str.length() != 3) {
142 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
143 " bad string length.");
149 // '.' wildcard means: keep current side
150 if (!allow_wildcards || str[1] != '.') {
151 for (i = 0; i < 2; ++i) {
152 if (str[1] == side_char[i]) {
153 res = InsetQuotesParams::QuoteSide(i);
158 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
159 " bad side specification.");
168 InsetQuotesParams::QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
169 bool const allow_wildcards, QuoteLevel fb)
174 if (str.length() != 3) {
175 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
176 " bad string length.");
182 // '.' wildcard means: keep current level
183 if (!allow_wildcards || str[2] != '.') {
184 for (i = 0; i < 2; ++i) {
185 if (str[2] == level_char[i]) {
186 res = InsetQuotesParams::QuoteLevel(i);
191 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
192 " bad level specification.");
193 res = InsetQuotesParams::PrimaryQuotes;
201 char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel const & level,
202 QuoteSide const & side, bool const rtl) const
204 // main opening quotation mark
205 char_type left_primary;
206 // main closing quotation mark
207 char_type right_primary;
208 // secondary (inner, 'single') opening quotation mark
209 char_type left_secondary;
210 // secondary (inner, 'single') closing quotation mark
211 char_type right_secondary;
214 case EnglishQuotes: {
215 left_primary = 0x201c; // ``
216 right_primary = 0x201d; // ''
217 left_secondary = 0x2018; // `
218 right_secondary = 0x2019; // '
221 case SwedishQuotes: {
222 left_primary = 0x201d; // ''
223 right_primary = 0x201d; // ''
224 left_secondary = 0x2019; // '
225 right_secondary = 0x2019; // '
229 left_primary = 0x201e; // ,,
230 right_primary = 0x201c; // ``
231 left_secondary = 0x201a; // ,
232 right_secondary = 0x2018; // `
236 left_primary = 0x201e; // ,,
237 right_primary = 0x201d; // ''
238 left_secondary = 0x201a; // ,
239 right_secondary = 0x2019; // '
243 left_primary = 0x00ab; // <<
244 right_primary = 0x00bb; // >>
245 left_secondary = 0x2039; // <
246 right_secondary = 0x203a; // >
250 left_primary = 0x00bb; // >>
251 right_primary = 0x00ab; // <<
252 left_secondary = 0x203a; // >
253 right_secondary = 0x2039; // <
257 left_primary = 0x0022; // "
258 right_primary = 0x0022; // "
259 left_secondary = 0x0027; // '
260 right_secondary = 0x0027; // '
263 case BritishQuotes: {
264 left_primary = 0x2018; // `
265 right_primary = 0x2019; // '
266 left_secondary = 0x201c; // ``
267 right_secondary = 0x201d; // ''
270 case SwedishGQuotes: {
271 left_primary = 0x00bb; // >>
272 right_primary = 0x00bb; // >>
273 left_secondary = 0x2019; // '
274 right_secondary = 0x2019; // '
278 left_primary = 0x00ab; // <<
279 right_primary = 0x00bb; // >>
280 left_secondary = 0x201c; // ``
281 right_secondary = 0x201d; // ''
284 case FrenchINQuotes:{
285 left_primary = 0x00ab; // <<
286 right_primary = 0x00bb; // >>
287 left_secondary = 0x00ab; // <<
288 right_secondary = 0x00bb; // >>
292 left_primary = 0x00ab; // <<
293 right_primary = 0x00bb; // >>
294 left_secondary = 0x201e; // ,,
295 right_secondary = 0x201c; // ``
299 left_primary = 0x300c; // LEFT CORNER BRACKET
300 right_primary = 0x300d; // RIGHT CORNER BRACKET
301 left_secondary = 0x300e; // LEFT WHITE CORNER BRACKET
302 right_secondary = 0x300f; // RIGHT WHITE CORNER BRACKET
305 case CJKAngleQuotes:{
306 left_primary = 0x300a; // LEFT DOUBLE ANGLE BRACKET
307 right_primary = 0x300b; // RIGHT DOUBLE ANGLE BRACKET
308 left_secondary = 0x3008; // LEFT ANGLE BRACKET
309 right_secondary = 0x3009; // RIGHT ANGLE BRACKET
315 left_primary = 0x003f; // ?
316 right_primary = 0x003f; // ?
317 left_secondary = 0x003f; // ?
318 right_secondary = 0x003f; // ?
323 case SecondaryQuotes:
325 return (side == ClosingQuote) ? left_secondary : right_secondary;
326 return (side == OpeningQuote) ? left_secondary : right_secondary;
329 return (side == ClosingQuote) ? left_primary : right_primary;
330 return (side == OpeningQuote) ? left_primary : right_primary;
340 docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op,
341 bool const rtl) const
350 res = "\\quotesinglbase";
355 // This macro is redefined in rtl mode
356 res = rtl ? "\\textquoteright" : "\\textquoteleft";
363 // This macro is redefined in rtl mode
364 res = rtl ? "\\textquoteleft" : "\\textquoteright";
373 res = "\\guilsinglleft";
380 res = "\\guilsinglright";
383 case 0x0027: {// ' (plain)
384 res = "\\textquotesingle";
390 else if (op == "babel")
393 res = "\\quotedblbase";
398 // This macro is redefined in rtl mode
399 res = rtl ? "\\textquotedblright" : "\\textquotedblleft";
406 // This macro is redefined in rtl mode
407 res = rtl ? "\\textquotedblleft" : "\\textquotedblright";
415 else if (op == "babel")
418 res = "\\guillemotleft";
424 else if (op == "babel")
427 res = "\\guillemotright";
431 res = "\\textquotedbl";
434 // The following are fakes
435 // This is just to get something symbolic
436 // in encodings where this chars would not be used ayway
437 case 0x300c: // LEFT CORNER BRACKET
438 res = "\\ensuremath{\\lceil}";
440 case 0x300d: // RIGHT CORNER BRACKET
441 res = "\\ensuremath{\\rfloor}";
443 case 0x300e: // LEFT WHITE CORNER BRACKET
444 res = "\\ensuremath{\\llceil}";
446 case 0x300f: // RIGHT WHITE CORNER BRACKET
447 res = "\\ensuremath{\\rrfloor}";
449 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
450 res = "\\ensuremath{\\langle\\kern-2.5pt\\langle}";
452 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
453 res = "\\ensuremath{\\rangle\\kern-2.5pt\\rangle}";
455 case 0x3008: // LEFT ANGLE BRACKET
456 res = "\\ensuremath{\\langle}";
458 case 0x3009: // RIGHT ANGLE BRACKET
459 res = "\\ensuremath{\\rangle}";
465 return from_ascii(res);
469 docstring InsetQuotesParams::getHTMLQuote(char_type c) const
489 case 0x0027: // ' (plain)
510 case 0x300c: // LEFT CORNER BRACKET
513 case 0x300d: // RIGHT CORNER BRACKET
516 case 0x300e: // LEFT WHITE CORNER BRACKET
519 case 0x300f: // RIGHT WHITE CORNER BRACKET
522 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
525 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
528 case 0x3008: // LEFT ANGLE BRACKET
531 case 0x3009: // RIGHT ANGLE BRACKET
538 return from_ascii(res);
542 map<string, docstring> InsetQuotesParams::getTypes() const
544 map<string, docstring> res;
552 // get all quote types
553 for (sty = 0; sty < stylescount(); ++sty) {
554 style = QuoteStyle(sty);
555 if (style == DynamicQuotes)
557 for (sid = 0; sid < 2; ++sid) {
558 side = QuoteSide(sid);
559 for (lev = 0; lev < 2; ++lev) {
560 type += style_char[style];
561 type += side_char[sid];
562 level = QuoteLevel(lev);
563 type += level_char[lev];
564 res[type] = docstring(1, getQuoteChar(style, level, side));
573 docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langdef)
575 docstring const styledesc =
576 bformat(_("%1$souter%2$s and %3$sinner%4$s[[quotation marks]]"),
577 docstring(1, getQuoteChar(qs, PrimaryQuotes, OpeningQuote)),
578 docstring(1, getQuoteChar(qs, PrimaryQuotes, ClosingQuote)),
579 docstring(1, getQuoteChar(qs, SecondaryQuotes, OpeningQuote)),
580 docstring(1, getQuoteChar(qs, SecondaryQuotes, ClosingQuote))
586 return bformat(_("%1$s[[quot. mark description]] (language default)"),
591 docstring const InsetQuotesParams::getShortGuiLabel(docstring const string)
593 std::string const s = to_ascii(string);
594 QuoteStyle const style = getQuoteStyle(s);
595 QuoteSide const side = getQuoteSide(s);
596 QuoteLevel const level = getQuoteLevel(s);
598 return (side == OpeningQuote) ?
599 bformat(_("%1$stext"),
600 docstring(1, getQuoteChar(style, level, side))) :
601 bformat(_("text%1$s"),
602 docstring(1, getQuoteChar(style, level, side)));
606 /////////////////////////////////////////////////////////////////////
610 ///////////////////////////////////////////////////////////////////////
612 InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
614 style_(InsetQuotesParams::EnglishQuotes), side_(InsetQuotesParams::OpeningQuote),
615 pass_thru_(false), internal_fontenc_(false), rtl_(false)
618 global_style_ = buf->masterBuffer()->params().quotes_style;
619 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
622 global_style_ = InsetQuotesParams::EnglishQuotes;
630 InsetQuotes::InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
631 string const & side, string const & style)
632 : Inset(buf), level_(level), pass_thru_(false), fontspec_(false),
633 internal_fontenc_(false), rtl_(false)
635 bool dynamic = false;
637 global_style_ = buf->masterBuffer()->params().quotes_style;
638 fontenc_ = buf->masterBuffer()->params().main_font_encoding();
639 dynamic = buf->masterBuffer()->params().dynamic_quotes;
640 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
642 global_style_ = InsetQuotesParams::EnglishQuotes;
647 style_ = dynamic ? InsetQuotesParams::DynamicQuotes : global_style_;
649 style_ = getStyle(style);
651 if (side == "left" || side == "opening")
652 side_ = InsetQuotesParams::OpeningQuote;
653 else if (side == "right" || side == "closing")
654 side_ = InsetQuotesParams::ClosingQuote;
660 docstring InsetQuotes::layoutName() const
662 return from_ascii("Quotes");
666 void InsetQuotes::setSide(char_type c)
668 // Decide whether opening or closing quote
669 if (lyx::isSpace(c) || isOpenPunctuation(c))
670 side_ = InsetQuotesParams::OpeningQuote;// opening quote
672 side_ = InsetQuotesParams::ClosingQuote;// closing quote
676 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
678 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
679 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
680 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
684 InsetQuotesParams::QuoteStyle InsetQuotes::getStyle(string const & s)
686 InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::EnglishQuotes;
689 qs = InsetQuotesParams::EnglishQuotes;
690 else if (s == "swedish")
691 qs = InsetQuotesParams::SwedishQuotes;
692 else if (s == "german")
693 qs = InsetQuotesParams::GermanQuotes;
694 else if (s == "polish")
695 qs = InsetQuotesParams::PolishQuotes;
696 else if (s == "swiss")
697 qs = InsetQuotesParams::SwissQuotes;
698 else if (s == "danish")
699 qs = InsetQuotesParams::DanishQuotes;
700 else if (s == "plain")
701 qs = InsetQuotesParams::PlainQuotes;
702 else if (s == "british")
703 qs = InsetQuotesParams::BritishQuotes;
704 else if (s == "swedishg")
705 qs = InsetQuotesParams::SwedishGQuotes;
706 else if (s == "french")
707 qs = InsetQuotesParams::FrenchQuotes;
708 else if (s == "frenchin")
709 qs = InsetQuotesParams::FrenchINQuotes;
710 else if (s == "russian")
711 qs = InsetQuotesParams::RussianQuotes;
713 qs = InsetQuotesParams::CJKQuotes;
714 else if (s == "cjkangle")
715 qs = InsetQuotesParams::CJKAngleQuotes;
716 else if (s == "dynamic")
717 qs = InsetQuotesParams::DynamicQuotes;
723 docstring InsetQuotes::displayString() const
725 // In PassThru, we use straight quotes
727 return (level_ == InsetQuotesParams::PrimaryQuotes) ?
728 from_ascii("\"") : from_ascii("'");
730 InsetQuotesParams::QuoteStyle style =
731 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
733 docstring retdisp = docstring(1, quoteparams.getQuoteChar(style, level_, side_, rtl_));
735 // in French, thin spaces are added inside double guillemets
736 if (prefixIs(context_lang_, "fr")
737 && level_ == InsetQuotesParams::PrimaryQuotes
738 && (style == InsetQuotesParams::SwissQuotes
739 || style == InsetQuotesParams::FrenchQuotes
740 || style == InsetQuotesParams::FrenchINQuotes)) {
741 // THIN SPACE (U+2009)
742 char_type const thin_space = 0x2009;
743 if (side_ == InsetQuotesParams::OpeningQuote)
744 retdisp += thin_space;
746 retdisp = thin_space + retdisp;
753 void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
755 FontInfo & font = mi.base.font;
756 frontend::FontMetrics const & fm = theFontMetrics(font);
757 dim.asc = fm.maxAscent();
758 dim.des = fm.maxDescent();
759 dim.wid = fm.width(displayString());
763 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
765 FontInfo font = pi.base.font;
766 if (style_ == InsetQuotesParams::DynamicQuotes)
767 font.setPaintColor(Color_special);
769 font.setPaintColor(pi.textColor(font.realColor()));
770 pi.pain.text(x, y, displayString(), font);
774 string InsetQuotes::getType() const
777 text += style_char[style_];
778 text += side_char[side_];
779 text += level_char[level_];
784 void InsetQuotes::write(ostream & os) const
786 os << "Quotes " << getType();
790 void InsetQuotes::read(Lexer & lex)
792 lex.setContext("InsetQuotes::read");
794 parseString(lex.getString());
795 lex >> "\\end_inset";
799 void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
801 switch (cmd.action()) {
802 case LFUN_INSET_MODIFY: {
803 string const first_arg = cmd.getArg(0);
804 bool const change_type = first_arg == "changetype";
807 // this will not be handled higher up
811 cur.recordUndoInset(this);
812 parseString(cmd.getArg(1), true);
813 cur.forceBufferUpdate();
817 Inset::doDispatch(cur, cmd);
823 bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd,
824 FuncStatus & flag) const
826 switch (cmd.action()) {
828 case LFUN_INSET_MODIFY: {
829 string const first_arg = cmd.getArg(0);
830 if (first_arg == "changetype") {
831 string const type = cmd.getArg(1);
832 flag.setOnOff(type == getType());
833 flag.setEnabled(!pass_thru_);
836 return Inset::getStatus(cur, cmd, flag);
840 return Inset::getStatus(cur, cmd, flag);
845 void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
847 InsetQuotesParams::QuoteStyle style =
848 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
849 char_type quotechar = quoteparams.getQuoteChar(style, level_, side_, rtl_);
852 // In pass-thru context, we output plain quotes
853 if (runparams.pass_thru)
854 qstr = (level_ == InsetQuotesParams::PrimaryQuotes) ? from_ascii("\"") : from_ascii("'");
855 else if (style == InsetQuotesParams::PlainQuotes && fontspec_) {
856 // For XeTeX and LuaTeX,we need to disable mapping to get straight
857 // quotes. We define our own commands that do this
858 qstr = (level_ == InsetQuotesParams::PrimaryQuotes) ?
859 from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
861 else if (runparams.use_polyglossia) {
862 // For polyglossia, we directly output the respective unicode chars
863 // (spacing and kerning is then handled respectively)
864 qstr = docstring(1, quotechar);
866 // The CJK marks are not yet covered by utf8 inputenc (we don't have the entry in
867 // unicodesymbols, since we don't want to add fake synbols there).
868 else if (style == InsetQuotesParams::CJKQuotes || style == InsetQuotesParams::CJKAngleQuotes) {
869 if (runparams.encoding && runparams.encoding->name() != "utf8"
870 && runparams.encoding->encodable(quotechar))
871 qstr = docstring(1, quotechar);
873 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
875 else if ((style == InsetQuotesParams::SwissQuotes
876 || style == InsetQuotesParams::FrenchQuotes
877 || style == InsetQuotesParams::FrenchINQuotes)
878 && level_ == InsetQuotesParams::PrimaryQuotes
879 && prefixIs(runparams.local_font->language()->code(), "fr")) {
880 // Specific guillemets of French babel
881 // including correct French spacing
882 if (side_ == InsetQuotesParams::OpeningQuote)
883 qstr = from_ascii("\\og");
885 qstr = from_ascii("\\fg");
886 } else if (fontenc_ == "T1"
887 && !runparams.local_font->language()->internalFontEncoding()) {
888 // Quotation marks for T1 font encoding
890 qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
891 } else if (runparams.local_font->language()->internalFontEncoding()) {
892 // Quotation marks for internal font encodings
893 // (ligatures not featured)
894 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
895 #ifdef DO_USE_DEFAULT_LANGUAGE
896 } else if ((doclang == "default"
898 } else if ((!runparams.use_babel
900 || (fontenc_ != "T1" && fontenc_ != "OT1"))
901 || runparams.isFullUnicode()) {
902 // Standard quotation mark macros
903 // These are also used by babel
904 // without fontenc (XeTeX/LuaTeX)
905 qstr = quoteparams.getLaTeXQuote(quotechar, "ot1");
907 // Babel shorthand quotation marks (for T1/OT1)
908 qstr = quoteparams.getLaTeXQuote(quotechar, "babel");
911 if (!runparams.pass_thru) {
912 // Guard against unwanted ligatures with preceding text
913 char_type const lastchar = os.lastChar();
914 // LuaTeX does not respect {} as ligature breaker by design,
915 // see https://tex.stackexchange.com/q/349725/19291
916 docstring const nolig =
917 (runparams.flavor == OutputParams::LUATEX
918 || runparams.flavor == OutputParams::DVILUATEX) ?
919 from_ascii("\\/") : from_ascii("{}");
920 // !` ?` => !{}` ?{}`
921 if (prefixIs(qstr, from_ascii("`"))
922 && (lastchar == '!' || lastchar == '?'))
924 // ``` ''' ,,, <<< >>>
925 // => `{}`` '{}'' ,{},, <{}<< >{}>>
926 if (contains(from_ascii(",'`<>"), lastchar)
927 && prefixIs(qstr, lastchar))
933 if (prefixIs(qstr, from_ascii("\\")) && !suffixIs(qstr, '}'))
934 // properly terminate the command depending on the context
939 int InsetQuotes::plaintext(odocstringstream & os,
940 OutputParams const &, size_t) const
942 docstring const str = displayString();
948 docstring InsetQuotes::getQuoteEntity() const {
949 InsetQuotesParams::QuoteStyle style =
950 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
951 docstring res = quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_));
952 // in French, thin spaces are added inside double guillemets
953 if (prefixIs(context_lang_, "fr")
954 && level_ == InsetQuotesParams::PrimaryQuotes
955 && (style == InsetQuotesParams::FrenchQuotes
956 || style == InsetQuotesParams::FrenchINQuotes
957 || style == InsetQuotesParams::SwissQuotes)) {
958 // THIN SPACE (U+2009)
959 docstring const thin_space = from_ascii(" ");
960 if (side_ == InsetQuotesParams::OpeningQuote)
963 res = thin_space + res;
969 int InsetQuotes::docbook(odocstream & os, OutputParams const &) const
971 os << getQuoteEntity();
976 docstring InsetQuotes::xhtml(XHTMLStream & xs, OutputParams const &) const
978 xs << XHTMLStream::ESCAPE_NONE << getQuoteEntity();
983 void InsetQuotes::toString(odocstream & os) const
985 os << displayString();
989 void InsetQuotes::forOutliner(docstring & os, size_t const, bool const) const
991 os += displayString();
995 void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/)
997 BufferParams const & bp = buffer().masterBuffer()->params();
998 Font const & font = it.paragraph().getFontSettings(bp, it.pos());
999 pass_thru_ = it.paragraph().isPassThru();
1000 context_lang_ = font.language()->code();
1001 internal_fontenc_ = font.language()->internalFontEncoding();
1002 fontenc_ = bp.main_font_encoding();
1003 global_style_ = bp.quotes_style;
1004 fontspec_ = bp.useNonTeXFonts;
1005 rtl_ = font.isRightToLeft();
1009 void InsetQuotes::validate(LaTeXFeatures & features) const
1011 InsetQuotesParams::QuoteStyle style =
1012 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
1013 char_type type = quoteparams.getQuoteChar(style, level_, side_);
1015 // Handle characters that are not natively supported by
1016 // specific font encodings (we roll our own definitions)
1017 #ifdef DO_USE_DEFAULT_LANGUAGE
1018 if (features.bufferParams().language->lang() == "default"
1020 if (!features.useBabel()
1022 && !features.runparams().isFullUnicode() && fontenc_ != "T1") {
1025 features.require("quotesinglbase");
1028 features.require("guilsinglleft");
1031 features.require("guilsinglright");
1034 features.require("quotedblbase");
1037 features.require("guillemotleft");
1040 features.require("guillemotright");
1046 // Handle straight quotation marks. These need special care
1047 // in most output formats
1050 if (features.runparams().isFullUnicode() && fontspec_)
1051 features.require("textquotesinglep");
1053 features.require("textcomp");
1057 if (features.runparams().isFullUnicode() && fontspec_)
1058 features.require("textquotedblp");
1059 else if (fontenc_ != "T1" || internal_fontenc_)
1060 features.require("textquotedbl");
1063 // we fake these from math (also for utf8 inputenc
1064 // currently; see above)
1065 case 0x300e: // LEFT WHITE CORNER BRACKET
1066 case 0x300f: // RIGHT WHITE CORNER BRACKET
1067 if (!features.runparams().encoding
1068 || features.runparams().encoding->name() == "utf8"
1069 || !features.runparams().encoding->encodable(type))
1070 features.require("stmaryrd");
1078 string InsetQuotes::contextMenuName() const
1080 return "context-quote";