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 * x dynamic style (inherits document settings)
73 char const * const style_char = "esgpcaqbwfirjkx";
74 char const * const side_char = "lr" ;
75 char const * const level_char = "sd";
80 /////////////////////////////////////////////////////////////////////
84 ///////////////////////////////////////////////////////////////////////
86 InsetQuotesParams quoteparams;
89 int InsetQuotesParams::stylescount() const
91 return strlen(style_char);
95 char InsetQuotesParams::getStyleChar(QuoteStyle const & style) const
97 return style_char[style];
101 InsetQuotesParams::QuoteStyle InsetQuotesParams::getQuoteStyle(string const & s,
102 bool const allow_wildcards, QuoteStyle fb) const
107 if (str.length() != 3) {
108 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
109 " bad string length.");
113 // '.' wildcard means: keep current style
114 if (!allow_wildcards || str[0] != '.') {
116 for (i = 0; i < stylescount(); ++i) {
117 if (str[0] == style_char[i]) {
122 if (i >= stylescount()) {
123 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
124 " bad style specification.");
133 InsetQuotesParams::QuoteSide InsetQuotesParams::getQuoteSide(string const & s,
134 bool const allow_wildcards, QuoteSide fb) const
139 if (str.length() != 3) {
140 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
141 " bad string length.");
145 // '.' wildcard means: keep current side
146 if (!allow_wildcards || str[1] != '.') {
148 for (i = 0; i < 2; ++i) {
149 if (str[1] == side_char[i]) {
150 res = InsetQuotesParams::QuoteSide(i);
155 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
156 " bad side specification.");
165 InsetQuotesParams::QuoteLevel InsetQuotesParams::getQuoteLevel(string const & s,
166 bool const allow_wildcards, QuoteLevel fb) const
171 if (str.length() != 3) {
172 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
173 " bad string length.");
177 // '.' wildcard means: keep current level
178 if (!allow_wildcards || str[2] != '.') {
180 for (i = 0; i < 2; ++i) {
181 if (str[2] == level_char[i]) {
182 res = InsetQuotesParams::QuoteLevel(i);
187 LYXERR0("ERROR (InsetQuotes::InsetQuotes):"
188 " bad level specification.");
189 res = InsetQuotesParams::PrimaryQuotes;
197 char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel const & level,
198 QuoteSide const & side, bool const rtl) const
200 // main opening quotation mark
201 char_type left_primary;
202 // main closing quotation mark
203 char_type right_primary;
204 // secondary (inner, 'single') opening quotation mark
205 char_type left_secondary;
206 // secondary (inner, 'single') closing quotation mark
207 char_type right_secondary;
210 case EnglishQuotes: {
211 left_primary = 0x201c; // ``
212 right_primary = 0x201d; // ''
213 left_secondary = 0x2018; // `
214 right_secondary = 0x2019; // '
217 case SwedishQuotes: {
218 left_primary = 0x201d; // ''
219 right_primary = 0x201d; // ''
220 left_secondary = 0x2019; // '
221 right_secondary = 0x2019; // '
225 left_primary = 0x201e; // ,,
226 right_primary = 0x201c; // ``
227 left_secondary = 0x201a; // ,
228 right_secondary = 0x2018; // `
232 left_primary = 0x201e; // ,,
233 right_primary = 0x201d; // ''
234 left_secondary = 0x201a; // ,
235 right_secondary = 0x2019; // '
239 left_primary = 0x00ab; // <<
240 right_primary = 0x00bb; // >>
241 left_secondary = 0x2039; // <
242 right_secondary = 0x203a; // >
246 left_primary = 0x00bb; // >>
247 right_primary = 0x00ab; // <<
248 left_secondary = 0x203a; // >
249 right_secondary = 0x2039; // <
253 left_primary = 0x0022; // "
254 right_primary = 0x0022; // "
255 left_secondary = 0x0027; // '
256 right_secondary = 0x0027; // '
259 case BritishQuotes: {
260 left_primary = 0x2018; // `
261 right_primary = 0x2019; // '
262 left_secondary = 0x201c; // ``
263 right_secondary = 0x201d; // ''
266 case SwedishGQuotes: {
267 left_primary = 0x00bb; // >>
268 right_primary = 0x00bb; // >>
269 left_secondary = 0x2019; // '
270 right_secondary = 0x2019; // '
274 left_primary = 0x00ab; // <<
275 right_primary = 0x00bb; // >>
276 left_secondary = 0x201c; // ``
277 right_secondary = 0x201d; // ''
280 case FrenchINQuotes:{
281 left_primary = 0x00ab; // <<
282 right_primary = 0x00bb; // >>
283 left_secondary = 0x00ab; // <<
284 right_secondary = 0x00bb; // >>
288 left_primary = 0x00ab; // <<
289 right_primary = 0x00bb; // >>
290 left_secondary = 0x201e; // ,,
291 right_secondary = 0x201c; // ``
295 left_primary = 0x300c; // LEFT CORNER BRACKET
296 right_primary = 0x300d; // RIGHT CORNER BRACKET
297 left_secondary = 0x300e; // LEFT WHITE CORNER BRACKET
298 right_secondary = 0x300f; // RIGHT WHITE CORNER BRACKET
301 case CJKAngleQuotes:{
302 left_primary = 0x300a; // LEFT DOUBLE ANGLE BRACKET
303 right_primary = 0x300b; // RIGHT DOUBLE ANGLE BRACKET
304 left_secondary = 0x3008; // LEFT ANGLE BRACKET
305 right_secondary = 0x3009; // RIGHT ANGLE BRACKET
311 left_primary = 0x003f; // ?
312 right_primary = 0x003f; // ?
313 left_secondary = 0x003f; // ?
314 right_secondary = 0x003f; // ?
319 case SecondaryQuotes:
321 return (side == ClosingQuote) ? left_secondary : right_secondary;
322 return (side == OpeningQuote) ? left_secondary : right_secondary;
325 return (side == ClosingQuote) ? left_primary : right_primary;
326 return (side == OpeningQuote) ? left_primary : right_primary;
336 docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op,
337 bool const rtl) const
346 res = "\\quotesinglbase";
351 // This macro is redefined in rtl mode
352 res = rtl ? "\\textquoteleft" : "\\textquoteright";
359 // This macro is redefined in rtl mode
360 res = rtl ? "\\textquoteright" : "\\textquoteleft";
369 res = "\\guilsinglleft";
376 res = "\\guilsinglright";
379 case 0x0027: {// ' (plain)
380 res = "\\textquotesingle";
386 else if (op == "babel")
389 res = "\\quotedblbase";
394 // This macro is redefined in rtl mode
395 res = rtl ? "\\textquotedblleft" : "\\textquotedblright";
402 // This macro is redefined in rtl mode
403 res = rtl ? "\\textquotedblright" : "\\textquotedblleft";
411 else if (op == "babel")
414 res = "\\guillemotleft";
420 else if (op == "babel")
423 res = "\\guillemotright";
427 res = "\\textquotedbl";
430 // The following are fakes
431 // This is just to get something symbolic
432 // in encodings where this chars would not be used anyway
433 case 0x300c: // LEFT CORNER BRACKET
434 res = "\\ensuremath{\\lceil}";
436 case 0x300d: // RIGHT CORNER BRACKET
437 res = "\\ensuremath{\\rfloor}";
439 case 0x300e: // LEFT WHITE CORNER BRACKET
440 res = "\\ensuremath{\\llceil}";
442 case 0x300f: // RIGHT WHITE CORNER BRACKET
443 res = "\\ensuremath{\\rrfloor}";
445 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
446 res = "\\ensuremath{\\langle\\kern-2.5pt\\langle}";
448 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
449 res = "\\ensuremath{\\rangle\\kern-2.5pt\\rangle}";
451 case 0x3008: // LEFT ANGLE BRACKET
452 res = "\\ensuremath{\\langle}";
454 case 0x3009: // RIGHT ANGLE BRACKET
455 res = "\\ensuremath{\\rangle}";
461 return from_ascii(res);
465 docstring InsetQuotesParams::getHTMLQuote(char_type c) const
485 case 0x0027: // ' (plain)
506 case 0x300c: // LEFT CORNER BRACKET
509 case 0x300d: // RIGHT CORNER BRACKET
512 case 0x300e: // LEFT WHITE CORNER BRACKET
515 case 0x300f: // RIGHT WHITE CORNER BRACKET
518 case 0x300a: // LEFT DOUBLE ANGLE BRACKET
521 case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
524 case 0x3008: // LEFT ANGLE BRACKET
527 case 0x3009: // RIGHT ANGLE BRACKET
534 return from_ascii(res);
538 docstring InsetQuotesParams::getXMLQuote(char_type c) const
540 // Directly output the character Unicode form.
541 return from_ascii("&#" + to_string(c) + ";");
545 map<string, docstring> InsetQuotesParams::getTypes() const
547 map<string, docstring> res;
555 // get all quote types
556 for (sty = 0; sty < stylescount(); ++sty) {
557 style = QuoteStyle(sty);
558 if (style == DynamicQuotes)
560 for (sid = 0; sid < 2; ++sid) {
561 side = QuoteSide(sid);
562 for (lev = 0; lev < 2; ++lev) {
563 type += style_char[style];
564 type += side_char[sid];
565 level = QuoteLevel(lev);
566 type += level_char[lev];
567 res[type] = docstring(1, getQuoteChar(style, level, side));
576 docstring const InsetQuotesParams::getGuiLabel(QuoteStyle const & qs, bool langdef) const
578 docstring const styledesc =
579 bformat(_("%1$souter%2$s and %3$sinner%4$s[[quotation marks]]"),
580 docstring(1, getQuoteChar(qs, PrimaryQuotes, OpeningQuote)),
581 docstring(1, getQuoteChar(qs, PrimaryQuotes, ClosingQuote)),
582 docstring(1, getQuoteChar(qs, SecondaryQuotes, OpeningQuote)),
583 docstring(1, getQuoteChar(qs, SecondaryQuotes, ClosingQuote))
589 return bformat(_("%1$s[[quot. mark description]] (language default)"),
594 docstring const InsetQuotesParams::getShortGuiLabel(docstring const & str) const
596 string const s = to_ascii(str);
597 QuoteStyle const style = getQuoteStyle(s);
598 QuoteSide const side = getQuoteSide(s);
599 QuoteLevel const level = getQuoteLevel(s);
601 return (side == OpeningQuote) ?
602 bformat(_("%1$stext"),
603 docstring(1, getQuoteChar(style, level, side))) :
604 bformat(_("text%1$s"),
605 docstring(1, getQuoteChar(style, level, side)));
609 /////////////////////////////////////////////////////////////////////
613 ///////////////////////////////////////////////////////////////////////
615 InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
619 global_style_ = buf->masterBuffer()->params().quotes_style;
620 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
627 InsetQuotes::InsetQuotes(Buffer * buf, char_type c, InsetQuotesParams::QuoteLevel level,
628 string const & side, string const & style)
629 : Inset(buf), level_(level)
631 bool dynamic = false;
633 global_style_ = buf->masterBuffer()->params().quotes_style;
634 fontenc_ = buf->masterBuffer()->params().main_font_encoding();
635 dynamic = buf->masterBuffer()->params().dynamic_quotes;
636 fontspec_ = buf->masterBuffer()->params().useNonTeXFonts;
641 style_ = dynamic ? InsetQuotesParams::DynamicQuotes : global_style_;
643 style_ = getStyle(style);
645 if (side == "left" || side == "opening")
646 side_ = InsetQuotesParams::OpeningQuote;
647 else if (side == "right" || side == "closing")
648 side_ = InsetQuotesParams::ClosingQuote;
654 docstring InsetQuotes::layoutName() const
656 return from_ascii("Quotes");
660 void InsetQuotes::setSide(char_type c)
662 // Decide whether opening or closing quote
663 if (lyx::isSpace(c) || isOpenPunctuation(c))
664 side_ = InsetQuotesParams::OpeningQuote;// opening quote
666 side_ = InsetQuotesParams::ClosingQuote;// closing quote
670 void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
672 style_ = quoteparams.getQuoteStyle(s, allow_wildcards, style_);
673 side_ = quoteparams.getQuoteSide(s, allow_wildcards, side_);
674 level_ = quoteparams.getQuoteLevel(s, allow_wildcards, level_);
678 InsetQuotesParams::QuoteStyle InsetQuotes::getStyle(string const & s)
680 InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::EnglishQuotes;
683 qs = InsetQuotesParams::EnglishQuotes;
684 else if (s == "swedish")
685 qs = InsetQuotesParams::SwedishQuotes;
686 else if (s == "german")
687 qs = InsetQuotesParams::GermanQuotes;
688 else if (s == "polish")
689 qs = InsetQuotesParams::PolishQuotes;
690 else if (s == "swiss")
691 qs = InsetQuotesParams::SwissQuotes;
692 else if (s == "danish")
693 qs = InsetQuotesParams::DanishQuotes;
694 else if (s == "plain")
695 qs = InsetQuotesParams::PlainQuotes;
696 else if (s == "british")
697 qs = InsetQuotesParams::BritishQuotes;
698 else if (s == "swedishg")
699 qs = InsetQuotesParams::SwedishGQuotes;
700 else if (s == "french")
701 qs = InsetQuotesParams::FrenchQuotes;
702 else if (s == "frenchin")
703 qs = InsetQuotesParams::FrenchINQuotes;
704 else if (s == "russian")
705 qs = InsetQuotesParams::RussianQuotes;
707 qs = InsetQuotesParams::CJKQuotes;
708 else if (s == "cjkangle")
709 qs = InsetQuotesParams::CJKAngleQuotes;
710 else if (s == "dynamic")
711 qs = InsetQuotesParams::DynamicQuotes;
717 docstring InsetQuotes::displayString() const
719 // In PassThru, we use straight quotes
721 return (level_ == InsetQuotesParams::PrimaryQuotes) ?
722 from_ascii("\"") : from_ascii("'");
724 InsetQuotesParams::QuoteStyle style =
725 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
727 docstring retdisp = docstring(1, quoteparams.getQuoteChar(style, level_, side_, rtl_));
729 // in French, thin spaces are added inside double guillemets
730 if (prefixIs(context_lang_, "fr")
731 && level_ == InsetQuotesParams::PrimaryQuotes
732 && (style == InsetQuotesParams::SwissQuotes
733 || style == InsetQuotesParams::FrenchQuotes
734 || style == InsetQuotesParams::FrenchINQuotes)) {
735 // THIN SPACE (U+2009)
736 char_type const thin_space = 0x2009;
737 if (side_ == InsetQuotesParams::OpeningQuote)
738 retdisp += thin_space;
740 retdisp = thin_space + retdisp;
747 void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
749 FontInfo & font = mi.base.font;
750 frontend::FontMetrics const & fm = theFontMetrics(font);
751 dim.asc = fm.maxAscent();
752 dim.des = fm.maxDescent();
753 dim.wid = fm.width(displayString());
757 void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
759 FontInfo font = pi.base.font;
760 if (style_ == InsetQuotesParams::DynamicQuotes)
761 font.setPaintColor(Color_special);
763 font.setPaintColor(pi.textColor(font.realColor()));
764 pi.pain.text(x, y, displayString(), font);
768 string InsetQuotes::getType() const
771 text += style_char[style_];
772 text += side_char[side_];
773 text += level_char[level_];
778 void InsetQuotes::write(ostream & os) const
780 os << "Quotes " << getType();
784 void InsetQuotes::read(Lexer & lex)
786 lex.setContext("InsetQuotes::read");
788 parseString(lex.getString());
789 lex >> "\\end_inset";
793 void InsetQuotes::doDispatch(Cursor & cur, FuncRequest & cmd)
795 switch (cmd.action()) {
796 case LFUN_INSET_MODIFY: {
797 string const first_arg = cmd.getArg(0);
798 bool const change_type = first_arg == "changetype";
801 // this will not be handled higher up
805 cur.recordUndoInset(this);
806 parseString(cmd.getArg(1), true);
807 cur.forceBufferUpdate();
811 Inset::doDispatch(cur, cmd);
817 bool InsetQuotes::getStatus(Cursor & cur, FuncRequest const & cmd,
818 FuncStatus & flag) const
820 switch (cmd.action()) {
822 case LFUN_INSET_MODIFY: {
823 string const first_arg = cmd.getArg(0);
824 if (first_arg == "changetype") {
825 string const type = cmd.getArg(1);
826 flag.setOnOff(type == getType());
827 flag.setEnabled(!pass_thru_);
830 return Inset::getStatus(cur, cmd, flag);
834 return Inset::getStatus(cur, cmd, flag);
839 void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
841 InsetQuotesParams::QuoteStyle style =
842 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
843 char_type quotechar = quoteparams.getQuoteChar(style, level_, side_, rtl_);
846 // In pass-thru context, we output plain quotes
847 if (runparams.pass_thru)
848 qstr = (level_ == InsetQuotesParams::PrimaryQuotes) ? from_ascii("\"") : from_ascii("'");
849 else if (style == InsetQuotesParams::PlainQuotes && fontspec_) {
850 // For XeTeX and LuaTeX,we need to disable mapping to get straight
851 // quotes. We define our own commands that do this
852 qstr = (level_ == InsetQuotesParams::PrimaryQuotes) ?
853 from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
855 else if (runparams.use_polyglossia) {
856 // For polyglossia, we directly output the respective unicode chars
857 // (spacing and kerning is then handled respectively)
858 qstr = docstring(1, quotechar);
860 // The CJK marks are not yet covered by utf8 inputenc (we don't have the entry in
861 // unicodesymbols, since we don't want to add fake synbols there).
862 else if (style == InsetQuotesParams::CJKQuotes || style == InsetQuotesParams::CJKAngleQuotes) {
863 if (runparams.encoding && runparams.encoding->name() != "utf8"
864 && runparams.encoding->encodable(quotechar))
865 qstr = docstring(1, quotechar);
867 qstr = quoteparams.getLaTeXQuote(quotechar, "int");
869 else if ((style == InsetQuotesParams::SwissQuotes
870 || style == InsetQuotesParams::FrenchQuotes
871 || style == InsetQuotesParams::FrenchINQuotes)
872 && level_ == InsetQuotesParams::PrimaryQuotes
873 && prefixIs(runparams.local_font->language()->code(), "fr")) {
874 // Specific guillemets of French babel
875 // including correct French spacing
876 if (side_ == InsetQuotesParams::OpeningQuote)
877 qstr = from_ascii("\\og");
879 qstr = from_ascii("\\fg");
880 } else if (runparams.use_hyperref && runparams.moving_arg) {
881 // Use internal commands in headings with hyperref
882 // (ligatures not featured in PDF strings)
883 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
884 } else if (fontenc_ == "T1"
885 && !runparams.local_font->language()->internalFontEncoding()) {
886 // Quotation marks for T1 font encoding
888 qstr = quoteparams.getLaTeXQuote(quotechar, "t1");
889 } else if (runparams.local_font->language()->internalFontEncoding()) {
890 // Quotation marks for internal font encodings
891 // (ligatures not featured)
892 qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_);
893 #ifdef DO_USE_DEFAULT_LANGUAGE
894 } else if ((doclang == "default"
896 } else if ((!runparams.use_babel
898 || (fontenc_ != "T1" && fontenc_ != "OT1"))
899 || runparams.isFullUnicode()) {
900 // Standard quotation mark macros
901 // These are also used by babel
902 // without fontenc (XeTeX/LuaTeX)
903 qstr = quoteparams.getLaTeXQuote(quotechar, "ot1");
905 // Babel shorthand quotation marks (for T1/OT1)
906 qstr = quoteparams.getLaTeXQuote(quotechar, "babel");
909 if (!runparams.pass_thru) {
910 // Guard against unwanted ligatures with preceding text
911 char_type const lastchar = os.lastChar();
912 // LuaTeX does not respect {} as ligature breaker by design,
913 // see https://tex.stackexchange.com/q/349725/19291
914 docstring const nolig =
915 (runparams.flavor == FLAVOR::LUATEX
916 || runparams.flavor == FLAVOR::DVILUATEX) ?
917 from_ascii("\\/") : from_ascii("{}");
918 // !` ?` => !{}` ?{}`
919 if (prefixIs(qstr, from_ascii("`"))
920 && (lastchar == '!' || lastchar == '?'))
922 // ``` ''' ,,, <<< >>>
923 // => `{}`` '{}'' ,{},, <{}<< >{}>>
924 if (contains(from_ascii(",'`<>"), lastchar)
925 && prefixIs(qstr, lastchar))
931 if (prefixIs(qstr, from_ascii("\\")) && !suffixIs(qstr, '}'))
932 // properly terminate the command depending on the context
937 int InsetQuotes::plaintext(odocstringstream & os,
938 OutputParams const &, size_t) const
940 docstring const str = displayString();
946 docstring InsetQuotes::getQuoteEntity(bool isHTML) const {
947 InsetQuotesParams::QuoteStyle style =
948 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
949 docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) :
950 quoteparams.getXMLQuote(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) // Open quote: space after
962 else // Close quote: space before
963 res = thin_space + res;
969 void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const
971 xs << XMLStream::ESCAPE_NONE << getQuoteEntity(false);
975 docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const
977 xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true);
982 void InsetQuotes::toString(odocstream & os) const
984 os << displayString();
988 void InsetQuotes::forOutliner(docstring & os, size_t const, bool const) const
990 os += displayString();
994 void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/, bool const /*deleted*/)
996 BufferParams const & bp = buffer().masterBuffer()->params();
997 Font const & font = it.paragraph().getFontSettings(bp, it.pos());
998 pass_thru_ = it.paragraph().isPassThru();
999 context_lang_ = font.language()->code();
1000 internal_fontenc_ = font.language()->internalFontEncoding();
1001 fontenc_ = bp.main_font_encoding();
1002 global_style_ = bp.quotes_style;
1003 fontspec_ = bp.useNonTeXFonts;
1004 rtl_ = font.isRightToLeft();
1008 void InsetQuotes::validate(LaTeXFeatures & features) const
1010 InsetQuotesParams::QuoteStyle style =
1011 (style_ == InsetQuotesParams::DynamicQuotes) ? global_style_ : style_;
1012 char_type type = quoteparams.getQuoteChar(style, level_, side_);
1014 // Handle characters that are not natively supported by
1015 // specific font encodings (we roll our own definitions)
1016 #ifdef DO_USE_DEFAULT_LANGUAGE
1017 if (features.bufferParams().language->lang() == "default"
1019 if (!features.useBabel()
1021 && !features.runparams().isFullUnicode() && fontenc_ != "T1") {
1024 features.require("quotesinglbase");
1027 features.require("guilsinglleft");
1030 features.require("guilsinglright");
1033 features.require("quotedblbase");
1036 features.require("guillemotleft");
1039 features.require("guillemotright");
1045 // Handle straight quotation marks. These need special care
1046 // in most output formats
1049 if (features.runparams().isFullUnicode() && fontspec_)
1050 features.require("textquotesinglep");
1052 features.require("textcomp");
1056 if (features.runparams().isFullUnicode() && fontspec_)
1057 features.require("textquotedblp");
1058 else if (fontenc_ != "T1" || internal_fontenc_)
1059 features.require("textquotedbl");
1062 // we fake these from math (also for utf8 inputenc
1063 // currently; see above)
1064 case 0x300e: // LEFT WHITE CORNER BRACKET
1065 case 0x300f: // RIGHT WHITE CORNER BRACKET
1066 if (!features.runparams().encoding
1067 || features.runparams().encoding->name() == "utf8"
1068 || !features.runparams().encoding->encodable(type))
1069 features.require("stmaryrd");
1077 string InsetQuotes::contextMenuName() const
1079 return "context-quote";