diff options
author | Norbert Preining <norbert@preining.info> | 2022-08-26 03:00:52 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-08-26 03:00:52 +0000 |
commit | 5e668640feb9f07a14456b8e7e413db0b1ec9561 (patch) | |
tree | 9b32a658597039087b1cafad8dcac574b403102d /macros/luatex | |
parent | 38aaa5ab119dae8bf21971e84c7742b2bfc591a5 (diff) |
CTAN sync 202208260300
Diffstat (limited to 'macros/luatex')
-rw-r--r-- | macros/luatex/latex/luaquotes/README | 14 | ||||
-rw-r--r-- | macros/luatex/latex/luaquotes/luaquotes-documentation.pdf | bin | 0 -> 106000 bytes | |||
-rw-r--r-- | macros/luatex/latex/luaquotes/luaquotes-documentation.tex | 1388 | ||||
-rw-r--r-- | macros/luatex/latex/luaquotes/luaquotes.sty | 310 |
4 files changed, 1712 insertions, 0 deletions
diff --git a/macros/luatex/latex/luaquotes/README b/macros/luatex/latex/luaquotes/README new file mode 100644 index 0000000000..b4e06d6d0c --- /dev/null +++ b/macros/luatex/latex/luaquotes/README @@ -0,0 +1,14 @@ +luaquotes - smart quotes with lua + +version: 1.0.0 + +This package automatically creates smart quotes using lua filters and provides auxiliary commands for typesetting specific lua punctuation + +This work may be distributed and/or modified under the conditions of the +LaTeX Project Public License (LPPL), version 1.3 or later. + + +For suggestions, feature requests, and bug reports, please use the project's +GitHub site: https://github.com/ezgranet/luaquotes + +Version history: 24/08/2022 —package creation diff --git a/macros/luatex/latex/luaquotes/luaquotes-documentation.pdf b/macros/luatex/latex/luaquotes/luaquotes-documentation.pdf Binary files differnew file mode 100644 index 0000000000..6383205e0a --- /dev/null +++ b/macros/luatex/latex/luaquotes/luaquotes-documentation.pdf diff --git a/macros/luatex/latex/luaquotes/luaquotes-documentation.tex b/macros/luatex/latex/luaquotes/luaquotes-documentation.tex new file mode 100644 index 0000000000..f6cbf32a17 --- /dev/null +++ b/macros/luatex/latex/luaquotes/luaquotes-documentation.tex @@ -0,0 +1,1388 @@ +\documentclass{article} +\usepackage{luaquotes} +\usepackage{verbatim} +\usepackage{xcolor} +\usepackage{longtable} +\definecolor{darkspringgreen}{rgb}{0.09, 0.45, 0.27} +\definecolor{dsg}{rgb}{0.09, 0.45, 0.27} +\usepackage[hidelinks]{hyperref} +\usepackage{hologo} +\usepackage[british]{babel} +\usepackage[useregional]{datetime2} +\DTMlangsetup[en-GB]{ord=omit} +\definecolor{LightGray}{gray}{0.9} +%\usepackage{mathpazo} +\IfFontExistsTF{Palatine Parliamentary}{\setromanfont[RawFeature={+onum,+pnum},% +BoldFont={Palatine Parliamentary Bold}, +ItalicFont={Palatine Parliamentary Italic}]{Palatine Parliamentary Regular} +}{\setromanfont[RawFeature={+onum,+pnum}]{TeX Gyre PagellaX}} +\setmonofont[Scale=.9]{Source Code Pro} +%\newfontface\primeback[Scale=1.01]{Libertinus Serif} +\newcommand{\primeback}{} + +\newfontface\boxy{DejaVu Sans} +\newcommand{\thebox}{{\boxy ▯}} +%\usepackage[firstnumber=last]{fancyvrb} +\usepackage{minted} +\date{\today\\\smallskip\ttfamily Version \luaquotesversionnumber} +\author{Elijah Z Granet\thanks{e-mail: \href{mailto:ezg21@cantab.ac.uk}{\ttfamily ezg21@cantab.ac.uk}}} + +\title{\texttt{LuaQuotes}:\\A package for smart quotation marks} + +\begin{document} +\maketitle +\tableofcontents +\clearpage +\section{Overview} +\subsection{Purpose} +This package provides a function to automatically have 'smart quotes' in \hologo{LuaLaTeX}. By 'smart quotes', I refer to the automatic insertion of curved or 'typographer's' quotation marks when the user types straight quotation marks. The below figure illustrates the distinction in English typography: +\begin{center} +\renewcommand{\arraystretch}{2} +\begin{tabular}{ccc} +\ttfamily User input &\color{red} Smart Quotes Off & \color{darkspringgreen}Smart Quotes On\\ +\LARGE\texttt{"Howdy!"}% +& \LARGE\textcolor{red}{\sqtworight}Howdy!\sqtworight% +& \LARGE "Howdy!"\\ +\LARGE\texttt{'Don't!'}% +& \LARGE\textcolor{red}{\sqoneright}% +Don\sqoneright t!\sqoneright% +& \LARGE 'Don't!' + +\end{tabular} +\end{center} +\section{Smart quotes} +\subsection{Options} + The default option, for English quotation marks, is called by: + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +breaklines, +] +{latex} +\usepackage{luaquotes} +\end{minted} +The French and German options, for those languages' punctuation, are called by the following respective commands. +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +breaklines, +] +{latex} +\usepackage[fr]{luaquotes} %French +\usepackage[de]{luaquotes} % German +\end{minted} + +\subsubsection{French option} +The French option produces the following output, including the extra space around punctuation prescribed by French typography: +\begin{center} +\renewcommand{\arraystretch}{2} +\begin{tabular}{cc} +\ttfamily User input &Output\\ +\LARGE\texttt{"Salut!"}% +& \LARGE \glmtl Salut!\glmtr\\ +\LARGE\texttt{'Salut!'}% +& \LARGE \sglmtl Salut!\sglmtr\\ + +\end{tabular} +\end{center} +\subsubsection{The German option} +The German option produces the following outpu: + +\begin{center} +\renewcommand{\arraystretch}{2} +\begin{tabular}{cc} +\ttfamily User input &Output\\ +\LARGE\texttt{"Hallo!"}% +& \LARGE \dedouble Hallo!\sqtwoleft\\ +\LARGE\texttt{'Hallo!'}% +& \LARGE \desingle Hallo!\sqoneleft\\ + +\end{tabular} +\end{center} + + + +\subsection{Activation and De-activation} +The package automatically activates the smart quotes function at the beginning of the document. To deactivate the smart quotes function within a document, the following commands are used: +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +breaklines, +] +{latex} +\dumbquotes %English +\frdumbquotes %French +\dedumbquotes %German +\end{minted} + +The following commands re-activate the smart quotes function: +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +breaklines, +] +{latex} +\smartquotes %English +\frsmartquotes %French +\desmartquotes % German +\end{minted} + +A limitation on the (de-)activation of the package is that the Lua filters will not deactivate within the same paragraph, so the function can only be changed across paragraphs. + +\subsection{Monospace} +As a general rule, smart quotes are rather undesirable in monospace text, and therefore, within the \color{darkspringgreen}\verb! \texttt!\color{black} environment the package does not apply smart quotes. Thus, the same input produces in roman face \textcolor{darkspringgreen}{"Hello World"} but in monospace \texttt{"Hello World"}. + + As the example above shows, the default behaviour of this package forces straight quotes in monospace, and disables \TeX\ quote ligatures (but not other \TeX\ ligatures) to do so, on the assumption that any form of curved quotes are undesirable. + + For extended periods of monospaced text called by {\color{darkspringgreen}\verb!\ttfamily!}, the activation and de-activation methods above should be used. I considered altering the {\color{darkspringgreen}\verb!\ttfamily!} command to always call on {\color{darkspringgreen}\verb!\dumbquotes!}, but I thought it best to avoid messing with the command. This may change in future development. + + + If a user desires to disable the smart quotes for other faces, this is easily done globally by adding the following line to the font's configuration in {\color{darkspringgreen}\texttt{fontspec}}: + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +breaklines, +] +{latex} +RawFeature={+qtbye} +\end{minted} +This will, however, result in the font using straight quotes rather than the standard \TeX\ quote ligatures, making it a distinct option than the activation and de-activation options \textit{supra}. +\section{Auxiliary Punctuation} +The smart quotes feature covers the 'standard' usage of quotes, but there are many instances where quotation mark or quote-mark like features are needed outside the automatic formatting. The package provides several commands for this. +\subsection{Standalone quotes} +The marks in this section are the set of quotation marks used generally in writing and require little explanation. However, it should be noted that the commands {\color{dsg}\verb!\sqoneright!} and {\color{dsg}\verb!\apost!} (which produce identical output) are very useful for aphetic words by which the first syllable is clipped, as in the sequence {\color{dsg}\texttt{'bout}} the smart quotes function will incorrectly produce an opening quote instead of the correct closing quote to indicate the elision. Thus, the incorrect result of {\color{red} 'bout} is produced. The solution is to use the code {\color{dsg}\verb!\apost bout!} which produces \textcolor{dsg}{\apost bout}. + +\begin{center} +\renewcommand{\arraystretch}{4} +\begin{longtable}{p{3cm}p{1.5cm}p{2cm}p{2.5cm}} +\textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\ +Single low quote & \ttfamily U+201A & \verb!\desingle! & \Huge\desingle\thebox\\ + Double low quote & \ttfamily U+201E & \verb!\dedouble! & \Huge\dedouble\thebox +\\ + Single straight quote & \ttfamily U+0027 & \verb!\dqone! & \Huge\dqone\thebox\\ + Double straight quote & \ttfamily U+0022 & \verb!\dqtwo! & \Huge\dqtwo\thebox\\ + Left single quote & \ttfamily U+2018 & \verb!\sqoneleft! & \Huge\sqoneleft\thebox\\ + Right single quote & \ttfamily U+2019 & \verb!\sqoneright! & \Huge\thebox\sqoneright\\ + Apostrophe & \ttfamily U+2019 & \verb!\apost! & \Huge\thebox\apost\\ + Left double quote & \ttfamily U+201C & \verb!\sqtwoleft! & \Huge\sqtwoleft\thebox\\ + Right double quote & \ttfamily U+201D & \verb!\sqtworight! & \Huge\thebox\sqtworight\\ + Left guillemet [w/ space]& \ttfamily U+00AB & \verb!\glmtl! & \Huge\glmtl\thebox\\ +Right guillemet [w/ space]& \ttfamily U+00BB & \verb!\glmtr! & \Huge\thebox\glmtr\\ +Single left guillemet [w/ space]& \ttfamily U+2039 & \verb!\sglmtl! & \Huge\sglmtl\thebox\\ + +Single right guillemet [w/ space]& \ttfamily U+203A & \verb!\sglmtr! & \Huge\thebox\sglmtr\\ + + +\end{longtable} + \end{center} + +\subsection{Additional symbols} +These are quote like symbols which are useful for precise punctuation, since standard smart quotation marks do not work well in their specialised use cases. + + +\begin{center} +\begin{longtable}{p{3cm}p{1.5cm}p{2cm}p{2.5cm}} +\textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\ + Backtick & \ttfamily U+0060 & \verb!\bcktck! & \Huge\bcktck\thebox +\end{longtable} + \end{center} +For typesetting US/Imperial measurements like feet and inches, the correct symbol is a prime and double prime. Many modern typefaces have these symbols, and they are thus useful for typesetting feet and inch measurements (like 6\primeback\lqprime\normalfont 4\primeback\lqdoubleprime ). + + +\begin{center} +\begin{longtable}{p{3cm}p{1.5cm}p{2.4cm}p{2.5cm}} +\textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\ + Single Prime & \ttfamily U+2032 & \verb!\lqprime! & \Huge\thebox\lqprime\\ + Double Prime & \ttfamily U+2033 & \verb!\lqdoubleprime! & \Huge\thebox\lqdoubleprime +\end{longtable} + \end{center} + +%\newcommand{\lqprime}{′} +%\newcommand{\lqdoubleprime}{″} + + + + +For certain Polynesian langauges, a letter called the \okina Okina is used; while this appears identical to a left single quotation mark in many fonts, it is encoded differently in Unicode because it is properly a letter, not a punctuation mark. + + + + + \begin{center} +\begin{longtable}{p{3cm}p{1.5cm}p{2cm}p{2.5cm}} +\textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\ + Okina & \ttfamily U+022B & \verb!\okina! & \Huge\okina\thebox\\\ + + +\end{longtable} +\end{center} + + + + + \section{Future Development and Localisation} + The package's online repository is the best place to report bugs, feature requests, or other contributions, and is located at: \\\url{github.com/ezgranet/luaquotes}. + + One obvious point of future development is the addition of other language localisations; this is technologically easy in principle but difficult for me to accomplish without assistance because it requires detailed knowledge of typographic conventions for any given language standard, and therefore the aid of contributors and collaborators. \section{Licence} + This project is licensed under the Latex Public Project Licence version 1.3\textit{c}. This documentation is copyright of the author but licensed under CC-BY-SA 3.0. + + + \clearpage\section{Implementation} + +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +\def\luaquotesversionnumber{1.0.0} +\ProvidesPackage{luaquotes} + [2022/08/01\luaquotesversionnumber smart quotes with lua] + % !TeX program = lualatex +% !TeX encoding = utf8 +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Elijah Z Granet +\end{minted} + +\subsection{LuaTeX check} + +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% to show the package only works with Lua +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{iftex} + \ifPDFTeX { + \PackageError{luaquotes} + {You are using pdfTeX but this package only works + \MessageBreak with LuaTeX}{} + } +\else\ifXeTeX{ \PackageError{luaquotes} + {You are using XeTeX but this package only works + \MessageBreak with LuaTeX}{} +}\fi\fi +\end{minted} + +\subsection{Dependencies} + +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Dependency +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{luacode} + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% fontspec for the auxiliary +% quotes where tligs need +% to be disabled +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{fontspec} + %%%%%%%%%%%%%%%%%%%%%%%%%%% + \end{minted} + + \subsection{Avoiding smart quotes in monospace} + +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% removing the effects for monospace +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{luacode} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +local uchar = unicode.utf8.char + fonts.handlers.otf.addfeature{ + name = "qtbye", + type = "substitution", + data = + { + “ = 0x0022, +” = 0x0022, +’ = 0x0027, +« = 0x0022, +» = 0x0022, +‹ = 0x0027, +› = 0x0027 + }, + }\end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + \end{luacode} + \end{minted} + \subsection{Quote replacement functions} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Code here and throughout similar +%functions partly adapted from TeX.SE user +% Mico +% https://tex.stackexchange.com/questions/499953/how-to-generate-correct-single-and-double-quotes-in-tex +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\luaexec{\end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function doublequotes ( s ) + return ( s:gsub ( '"(..-)"' , "“\%1”" ) ) + end\end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +} + + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Assuming ' at the start of the line means an opening quotation mark not an apostrophe +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\luaexec{\end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function singlequotelinestart ( s ) + return (s:gsub ("^'","‘" ) ) + end + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + } + +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function singlequotes ( s ) + return ( s:gsub ( " '"," ‘" ) ) + end\end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +} +\end{minted} +\subsection{Activation commands} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% activation and deactivation +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand\doublequoteson{\directlua{ +\end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} + +luatexbase.add_to_callback ( + "process_input_buffer" , doublequotes , "doublequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\doublequotesoff{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , + "doublequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +}} +\newcommand\singlequotelinestarton{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.add_to_callback ( + "process_input_buffer" , singlequotelinestart , "singlequotelinestart" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\singlequotelinestartoff{\directlua{ \end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "singlequotelinestart" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\singlequoteson{\directlua{ +luatexbase.add_to_callback ( + "process_input_buffer" , singlequotes , "singlequotes" ) \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\singlequotesoff{\directlua{ +\end{minted} +\begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "singlequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +}} + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% global functions, useful for things like this +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \newcommand{\smartquotes}{% +\doublequoteson% +\singlequotelinestarton% +\singlequoteson} + \newcommand{\dumbquotes}{\doublequotesoff + \singlequotelinestartoff + \singlequotesoff} + \end{minted} + \subsection{English option} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + + \DeclareOption{en}{ + +\AtBeginDocument{\smartquotes} +\renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}}\dumbquotes #1}} + + } + \end{minted} + \subsection{Auxiliary punctuation} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% auxiliary punctuation +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Essentially to be used where the +% thing fails to provide the +% quotation or +% quote like punctuation +% needed +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% German quotations +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\desingle}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"201A}}} +\newcommand{\dedouble}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"201E}}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% backtick +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\bcktck}{{\addfontfeature{RawFeature={-qtbye,-tlig}}`}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Straight double +% and single quotes +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand{\dqone}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"0027}}} +\newcommand{\dqtwo}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"0022}}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Prime, mostly for +% Feet and inches +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\lqprime}{′} +\newcommand{\lqdoubleprime}{″} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The Okina, for typing +% Hawaiʻi +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\okina}{ʻ} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The individual smart quotes +% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\sqtwoleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}“}} +\newcommand{\sqtworight}{{\addfontfeature{RawFeature={-qtbye,-tlig}}”}} +\newcommand{\sqoneright}{{\addfontfeature{RawFeature={-qtbye,-tlig}}’}} +\newcommand{\apost}{{\addfontfeature{RawFeature={-qtbye,-tlig}}’}} +\newcommand{\sqoneleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‘}} +\newcommand{\glmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}«\,}} +\newcommand{\glmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\,»}} +\newcommand{\sglmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‹\,}} +\newcommand{\sglmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\,›}} + \end{minted} + \subsection{The German option} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DEUTSCH +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function dedoublequotes ( s ) + return ( s:gsub ( '"(..-)"' , "„\%1“" ) ) + end + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + } +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function desinglequotelinestart ( s ) + return (s:gsub ("^'","‚" ) ) + end + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + } +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function desinglequotesclose( s ) +return ( s:gsub ( " '(..-)'", " ‚\%1`" ) ) + end + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + } + +%% Two utility macros to activate/deactivate the Lua function: +\newcommand\dedoublequoteson{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.add_to_callback ( + "process_input_buffer" , dedoublequotes , "dedoublequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\dedoublequotesoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "dedoublequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +}} +\newcommand\desinglequotelinestarton{\directlua{ +\end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.add_to_callback ( + "process_input_buffer" , desinglequotelinestart , "desinglequotelinestart" )\end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\desinglequotelinestartoff{\directlua{ +\end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "desinglequotelinestart" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\desinglequotescloseon{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} + luatexbase.add_to_callback ( + "process_input_buffer" , desinglequotesclose , "desinglequotesclose" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\desinglequotescloseoff{\directlua{ +\end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "desinglequotesclose" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} + \newcommand{\desmartquotes}{\dedoublequoteson +\desinglequotelinestarton +\desinglequoteson +\desinglequotescloseon} + \newcommand{\dedumbquotes}{\dedoublequotesoff +\desinglequotelinestartoff +\desinglequotesoff +\desinglequotescloseoff} + \DeclareOption{de}{ + +\AtBeginDocument{\desmartquotes} +\renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}}\dedumbquotes #1}} + + +} + \end{minted} + \subsection{The French option} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Français +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function frdoublequotes ( s ) + return ( s:gsub ( '"(..-)"' , "«\\,\%1\\,»" ) ) + end + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +} +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function frsinglequotelinestart ( s ) + return (s:gsub ("^'","'" ) ) + end \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +} +\luaexec{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +function frsinglequotesclose( s ) +return ( s:gsub ( " '(..-)'", " ‹\\,\%1\\,›" ) ) + end + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + } +%% Two utility macros to activate/deactivate the Lua function: +\newcommand\frdoublequoteson{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.add_to_callback ( + "process_input_buffer" ,frdoublequotes , "frdoublequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\frdoublequotesoff{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "frdoublequotes" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\frsinglequotelinestarton{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.add_to_callback ( + "process_input_buffer" ,frsinglequotelinestart , "frsinglequotelinestart" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} +\newcommand\frsinglequotelinestartoff{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "frsinglequotelinestart" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} + }} + \newcommand\frsinglequotescloseon{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} + luatexbase.add_to_callback ( + "process_input_buffer" ,frsinglequotesclose , "frsinglequotesclose" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +}} +\newcommand\frsinglequotescloseoff{\directlua{ + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{lua} +luatexbase.remove_from_callback ( + "process_input_buffer" , "frsinglequotesclose" ) + \end{minted} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +}} + \newcommand{\frsmartquotes}{\frdoublequoteson +\frsinglequotelinestarton +\frsinglequotescloseon} + \newcommand{\frdumbquotes}{\frdoublequotesoff +\frsinglequotelinestartoff +\frsinglequotescloseoff} \DeclareOption{fr}{ + +\AtBeginDocument{\frsmartquotes} +\renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}}\frdumbquotes #1}} + + +} + \end{minted} + \subsection{Process Options} + \begin{minted}[ +frame=lines, +framesep=2mm, +baselinestretch=1.2, +bgcolor=LightGray, +fontsize=\footnotesize, +linenos, +breaklines, +firstnumber=last +] +{latex} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Default option is English +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ExecuteOptions{en}% + \ProcessOptions* + + + +\end{minted} +\section{Version History} +\subsection{\texttt{1.0.0}} + +\ttfamily 21 August 2022: Package creation + + +\end{document}
\ No newline at end of file diff --git a/macros/luatex/latex/luaquotes/luaquotes.sty b/macros/luatex/latex/luaquotes/luaquotes.sty new file mode 100644 index 0000000000..f753df8183 --- /dev/null +++ b/macros/luatex/latex/luaquotes/luaquotes.sty @@ -0,0 +1,310 @@ +\def\luaquotesversionnumber{1.0.0} +\ProvidesPackage{luaquotes} + [2022/08/01\luaquotesversionnumber smart quotes with lua] + % !TeX program = lualatex +% !TeX encoding = utf8 +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Elijah Z Granet + + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% to show the package only works with Lua +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{iftex} + \ifPDFTeX { + \PackageError{luaquotes} + {You are using pdfTeX but this package only works + \MessageBreak with LuaTeX}{} + } +\else\ifXeTeX{ \PackageError{luaquotes} + {You are using XeTeX but this package only works + \MessageBreak with LuaTeX}{} +}\fi\fi +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Dependency +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{luacode} + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% fontspec for the auxiliary +% quotes where tligs need +% to be disabled +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \RequirePackage{fontspec} + %%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% removing the effects for monospace +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{luacode} +local uchar = unicode.utf8.char + fonts.handlers.otf.addfeature{ + name = "qtbye", + type = "substitution", + data = + { + “ = 0x0022, +” = 0x0022, +’ = 0x0027, +« = 0x0022, +» = 0x0022, +‹ = 0x0027, +› = 0x0027 + }, + } + \end{luacode} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Code here and throughout similar +%functions partly adapted from TeX.SE user +% Mico +% https://tex.stackexchange.com/questions/499953/how-to-generate-correct-single-and-double-quotes-in-tex +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\luaexec{ +function doublequotes ( s ) + return ( s:gsub ( '"(..-)"' , "“\%1”" ) ) + end} + + %%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Assuming ' at the start of the line means an opening quotation mark not an apostrophe +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\luaexec{function singlequotelinestart ( s ) + return (s:gsub ("^'","‘" ) ) + end} + +\luaexec{function singlequotes ( s ) + return ( s:gsub ( " '"," ‘" ) ) + end} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% activation and deactivation +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand\doublequoteson{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" , + doublequotes , + "doublequotes" )}} +\newcommand\doublequotesoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , + "doublequotes" )}} +\newcommand\singlequotelinestarton{\directlua{ +luatexbase.add_to_callback ( + "process_input_buffer" , singlequotelinestart , "singlequotelinestart" ) + }} +\newcommand\singlequotelinestartoff{\directlua{ +luatexbase.remove_from_callback ( + "process_input_buffer" , "singlequotelinestart" ) + }} +\newcommand\singlequoteson{\directlua{ +luatexbase.add_to_callback ( + "process_input_buffer" , singlequotes , "singlequotes" ) + }} +\newcommand\singlequotesoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "singlequotes" )}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% global functions, useful for things like this +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + \newcommand{\smartquotes}{% +\doublequoteson% +\singlequotelinestarton% +\singlequoteson} + \newcommand{\dumbquotes}{ + \doublequotesoff + \singlequotelinestartoff + \singlequotesoff} + + \DeclareOption{en}{ +\AtBeginDocument{\smartquotes} +\renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}} + } + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% auxiliary punctuation +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Essentially to be used where the +% thing fails to provide the +% quotation or +% quote like punctuation +% needed +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% German quotations +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\desingle}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"201A}}} +\newcommand{\dedouble}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"201E}}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% backtick +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\bcktck}{{\addfontfeature{RawFeature={-qtbye,-tlig}}`}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Straight double +% and single quotes +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand{\dqone}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"0027}}} +\newcommand{\dqtwo}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"0022}}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Prime, mostly for +% Feet and inches +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\lqprime}{′} +\newcommand{\lqdoubleprime}{″} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The Okina, for typing +% Hawaiʻi +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\okina}{ʻ} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% The individual smart quotes +% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcommand{\sqtwoleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}“}} +\newcommand{\sqtworight}{{\addfontfeature{RawFeature={-qtbye,-tlig}}”}} +\newcommand{\sqoneright}{{\addfontfeature{RawFeature={-qtbye,-tlig}}’}} +\newcommand{\apost}{{\addfontfeature{RawFeature={-qtbye,-tlig}}’}} +\newcommand{\sqoneleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‘}} +\newcommand{\glmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}«\,}} +\newcommand{\glmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\,»}} +\newcommand{\sglmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‹\,}} +\newcommand{\sglmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\,›}} +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DEUTSCH +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\luaexec{function dedoublequotes ( s ) + return ( s:gsub ( '"(..-)"' , "„\%1“" ) ) + end} +\luaexec{function desinglequotelinestart ( s ) + return (s:gsub ("^'","‚" ) ) + end} +\luaexec{function desinglequotesclose( s ) +return ( s:gsub ( " '(..-)'", " ‚\%1`" ) ) + end} + +%% Two utility macros to activate/deactivate the Lua function: +\newcommand\dedoublequoteson{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" , dedoublequotes , "dedoublequotes" )}} +\newcommand\dedoublequotesoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "dedoublequotes" )}} +\newcommand\desinglequotelinestarton{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" , desinglequotelinestart , "desinglequotelinestart" )}} +\newcommand\desinglequotelinestartoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "desinglequotelinestart" )}} + \newcommand\desinglequotescloseon{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" , desinglequotesclose , "desinglequotesclose" )}} +\newcommand\desinglequotescloseoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "desinglequotesclose" )}} + \newcommand{\desmartquotes}{\dedoublequoteson +\desinglequotelinestarton +\desinglequoteson +\desinglequotescloseon} + \newcommand{\dedumbquotes}{\dedoublequotesoff +\desinglequotelinestartoff +\desinglequotesoff +\desinglequotescloseoff} + \DeclareOption{de}{ + +\AtBeginDocument{\desmartquotes} +\renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}} + + +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Français +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\luaexec{function frdoublequotes ( s ) + return ( s:gsub ( '"(..-)"' , "«\\,\%1\\,»" ) ) + end} + + +\luaexec{function frsinglequotelinestart ( s ) + return (s:gsub ("^'","'" ) ) + end} +\luaexec{function frsinglequotesclose( s ) +return ( s:gsub ( " '(..-)'", " ‹\\,\%1\\,›" ) ) + end} + +%% Two utility macros to activate/deactivate the Lua function: +\newcommand\frdoublequoteson{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" ,frdoublequotes , "frdoublequotes" )}} +\newcommand\frdoublequotesoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "frdoublequotes" )}} +\newcommand\frsinglequotelinestarton{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" ,frsinglequotelinestart , "frsinglequotelinestart" )}} +\newcommand\frsinglequotelinestartoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "frsinglequotelinestart" )}} + \newcommand\frsinglequotescloseon{\directlua{luatexbase.add_to_callback ( + "process_input_buffer" ,frsinglequotesclose , "frsinglequotesclose" )}} +\newcommand\frsinglequotescloseoff{\directlua{luatexbase.remove_from_callback ( + "process_input_buffer" , "frsinglequotesclose" )}} + \newcommand{\frsmartquotes}{\frdoublequoteson +\frsinglequotelinestarton +\frsinglequotescloseon} + \newcommand{\frdumbquotes}{\frdoublequotesoff +\frsinglequotelinestartoff +\frsinglequotescloseoff} + \DeclareOption{fr}{ + +\AtBeginDocument{\frsmartquotes} +\renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}} + + +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Default option is English +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ExecuteOptions{en}% + \ProcessOptions* + + + + |