From ab5a34bb0e115a822ce300baee997608c943af86 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 23 Aug 2018 21:58:27 +0000 Subject: lualatex-truncate (23aug18) git-svn-id: svn://tug.org/texlive/trunk@48469 c570f23f-e606-0410-a88d-b1316a301751 --- .../lualatex-truncate/lualatex-truncate.dtx | 61 ++++++++++++++++------ 1 file changed, 46 insertions(+), 15 deletions(-) (limited to 'Master/texmf-dist/source/lualatex/lualatex-truncate/lualatex-truncate.dtx') diff --git a/Master/texmf-dist/source/lualatex/lualatex-truncate/lualatex-truncate.dtx b/Master/texmf-dist/source/lualatex/lualatex-truncate/lualatex-truncate.dtx index 69ad4b80885..06d035702a1 100644 --- a/Master/texmf-dist/source/lualatex/lualatex-truncate/lualatex-truncate.dtx +++ b/Master/texmf-dist/source/lualatex/lualatex-truncate/lualatex-truncate.dtx @@ -32,40 +32,55 @@ % % % +% \changes{1.0}{2018/06/03}{Initial release} +% \changes{1.1}{2018/08/22}{\textsc{\bfseries Bugfix:} visible hyphen char with \texttt{breakall} option and non-english language} +% % \subsubsection*{Initialization} % Identify the package and require \LaTeXe: % \begin{macrocode} \ProvidesPackage{lualatex-truncate}% - [2018/06/03 v1.0 LuaLaTeX wrapper for the truncate package] + [2018/08/22 v1.1 LuaLaTeX wrapper for the truncate package] \NeedsTeXFormat{LaTeX2e} % \end{macrocode} % % % % \subsubsection*{Internal variables} -% This internal variable is used to remember whether \enquote{hacking} the hyphenation character (i.e.~"\prehyphenchar") is required: +% This variable is used to remember whether messing with the hyphen char is required: % \begin{macrocode} \newif\if@lualtxtruncate@hackhyphen \@lualtxtruncate@hackhyphenfalse % \end{macrocode} % +% Also, enable remembering whether the \opt{breakall} option has been used: +% \begin{macrocode} +\newif\if@lualtxtruncate@breakall +\@lualtxtruncate@breakallfalse +% \end{macrocode} +% +% % % % \subsubsection*{Package options} % The \opt{breakwords} and \opt{breakall} options require the hyphanation character to be hidden. % Therefore, we remember to \enquote{hack} the hyphen character before passing these options -% to the original \sty{truncate} package: +% to the \enquote{original} \sty{truncate} package: % \begin{macrocode} \DeclareOption{breakwords}{% - \@lualtxtruncate@hackhyphentrue + \@lualtxtruncate@hackhyphentrue% \PassOptionsToPackage{breakwords}{truncate}} +% \end{macrocode} +% +% In case of the \opt{breakall} option, we also need to remember the option's usage: +% \begin{macrocode} \DeclareOption{breakall}{% - \@lualtxtruncate@hackhyphentrue + \@lualtxtruncate@breakalltrue% + \@lualtxtruncate@hackhyphentrue% \PassOptionsToPackage{breakall}{truncate}} % \end{macrocode} % % \smallskip -% Pass all other options (\opt{hyphenate} and \opt{fit}) directly to the \sty{truncate} package: +% Pass all other options (i.e. \opt{hyphenate} and \opt{fit}) directly to the \sty{truncate} package: % \begin{macrocode} \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{truncate}} % \end{macrocode} @@ -78,10 +93,17 @@ % % % -% \subsubsection*{Loading the \sty{truncate} package} -% Load the \sty{truncate} package. Required package options have already been passed on. +% \subsubsection*{Load the \sty{truncate} package} +% Require the \sty{truncate} package. All package options have already been passed on. \\ +% If \sty{truncate} has been loaded already, a error message is printed to the log. % \begin{macrocode} -\RequirePackage{truncate} +\@ifpackageloaded{truncate}{% + \PackageError{lualatex-truncate}% + {Don't load the truncate package when using lualatex-truncate!}% + {Don't load the truncate package and pass all package options + to lualatex-truncate! Otherwise, the wrapper mechanism won't + be able to understand what you want.}% +}{\RequirePackage{truncate}} % \end{macrocode} % % @@ -111,18 +133,27 @@ % \end{macro} % % \begin{macro}{\truncate} +% \changes{1.1}{2018/08/22}{Remember previous hyphenation character} % Construct the wrapper by redefining the "\truncate" command -% and -- if necessary -- modifying "\prehyphenchar": +% and -- if necessary -- modifying "\prehyphenchar". \\ +% "\prehyphenchar"'s value is stored inside the counter +% "\lualtxtruncate@tmp". Also, the current language must be set to US english, +% if the \opt{breakall} option has been used. % \begin{macrocode} -\renewcommand{\truncate}[3][\TruncateMarker]{% +\renewcommand{\truncate}[3][\TruncateMarker]{{% two braces -> scope changes + \if@lualtxtruncate@breakall% + \language\z@% force US english + \fi% + \newcount\lualtxtruncate@tmp% + \lualtxtruncate@tmp=\the\prehyphenchar% remember current hyphen char \if@lualtxtruncate@hackhyphen% - \prehyphenchar=0% + \prehyphenchar=0% invisible hyphen \fi% - \lualtxtruncate@truncate[#1]{#2}{#3}% + \lualtxtruncate@truncate[#1]{#2}{#3}% run the original \truncate macro \if@lualtxtruncate@hackhyphen% - \prehyphenchar=`\-% + \prehyphenchar=\the\lualtxtruncate@tmp% restore hyphen \fi% -} +}} % \end{macrocode} % \end{macro} % -- cgit v1.2.3