I had a hard time typing with Rt-to-Lt language and using quotes in LaTeX while keeping the font-locking of quotes. I use csquotes
package latest version (Version 5.1d -- 2011) for many advantages like toggling between different variants in a style. To make a long story short (see: https://tex.stackexchange.com/q/226097/26295) I want to have font-locking of text between two "
s.
How to do achieve this?
I want to have font-lock for the first line, i.e. between the two "
marks, using the same color of default quotes seen in the second line.
Code
\documentclass[twoside=semi]{scrbook}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq,abjadjimnotail=true]{arabic}
\newfontfamily\arabicfont[Script=Arabic,Ligatures=TeX]{Simplified Arabic}
\usepackage[style=arabic,arabic=quotes]{csquotes} % this is a custom style -- but it is not important for this font-lock question I think.
\MakeOuterQuote{"}
\begin{document}
هذا نص باللغة العربية "داخل علامتي الافتباس".
هذا نص باللغة العربية ``داخل علامتي الافتباس''.
هذا نص باللغة العربية \enquote{داخل علامتي الاقتباس}.
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
Notes
font-latex-quote
variable was set toauto
- face:
font-latex-string face
: foreground LightSalmon
Trial Code
The comments of lawlist
has put me on the right track but there is still the problem of that single "
in the preamble of \MakeOuterQuote{"}
as it interferes with the regexp code. The below code in the .init
gives the desired effect if that single unmatched "
in the preamble were not there:
(font-lock-add-keywords 'latex-mode (list (list "\\(\"\\)\\(\\(.\\|\n\\)+?\\)\\(\"\\)" '(1 'font-latex-string-face t) '(2 'font-latex-string-face t) '(3 'font-latex-string-face t) '(4 'font-latex-string-face t))))
Trial to avoid it
I used this regexp to avoid that single "
and that increased number of potential groups from 4 to 5.
\\(:?[^{]\\) in front of the previous regexp
So I put in in .init
:
(font-lock-add-keywords 'latex-mode (list (list "\\(:?[^{]\\)\\(\"\\)\\(\\(.\\|\n\\)+?\\)\\(\"\\)" '(2 'font-latex-string-face t) '(3 'font-latex-string-face t) '(4 'font-latex-string-face t) '(5 'font-latex-string-face t))))
M-x re-builder
So re-builder
for regexp confirms that the regexp is avoiding that single unmatched "
(not shown) and shows that there are now 5 regexp groups (1 blue, 2 green, 3 red, 4 blue, 5 green), but I want to font-lock all except group 1 which is the avoid group. However, the current problem is that font-lock won't take effect unless I hit enter of the quote line; as I write quoted text there is no font-lock until I hit enter then and only then it will take the effect. So am I missing something? is it because of the avoid group it doesn't font-lock immediately?
Suggestion as a workaround
Is it possible to enter that single "
as a unicode in the preamble to avoid being detected by the regexp?