[latex3-commits] [git/LaTeX3-latex3-latex3] master: l3doc class options for cs hyphenation (755e9eb)

Will Robertson will at wspr.io
Sat Sep 15 14:40:24 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/755e9eb7303bac9662fc05143d7c8c291c07265f

>---------------------------------------------------------------

commit 755e9eb7303bac9662fc05143d7c8c291c07265f
Author: Will Robertson <will at wspr.io>
Date:   Sat Sep 15 22:10:05 2018 +0930

    l3doc class options for cs hyphenation
    
    [cs-break-off]
    [cs-break-nohyphen]
    
    (not too fussed about the names. probably not perfect.)
    
    see #479


>---------------------------------------------------------------

755e9eb7303bac9662fc05143d7c8c291c07265f
 l3kernel/l3doc.dtx |   30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/l3kernel/l3doc.dtx b/l3kernel/l3doc.dtx
index 78a3ead..ba28265 100644
--- a/l3kernel/l3doc.dtx
+++ b/l3kernel/l3doc.dtx
@@ -281,6 +281,10 @@ and all files in that bundle must be distributed together.
 %     \item |replace| is a boolean key (\texttt{true} by default) which
 %       indicates whether to replace |@@| as \pkg{l3docstrip} does.
 %   \end{itemize}
+%   These commands allow hyphenation of control sequences after (most) underscores.
+%   By default, a hyphen is used to mark the hyphenation, but this can be changed with
+%   the \texttt{cs-break-nohyphen} class option.
+%   To disable hyphenation of control sequencies entirely, use \texttt{cs-break-off}.
 % \end{function}
 %
 %
@@ -687,6 +691,7 @@ and all files in that bundle must be distributed together.
 %     \g_@@_lmodern_bool,
 %     \g_@@_checkfunc_bool,
 %     \g_@@_checktest_bool,
+%     \g_@@_cs_break_bool,
 %     \g_@@_kernel_bool
 %   }
 %   Information about package options.
@@ -695,6 +700,8 @@ and all files in that bundle must be distributed together.
 \bool_new:N \g_@@_checkfunc_bool
 \bool_new:N \g_@@_checktest_bool
 \bool_new:N \g_@@_kernel_bool
+\bool_new:N \g_@@_cs_break_bool
+\bool_gset_true:N \g_@@_cs_break_bool
 %    \end{macrocode}
 % \end{variable}
 %
@@ -1412,6 +1419,13 @@ and all files in that bundle must be distributed together.
 %    \end{macrocode}
 %
 %    \begin{macrocode}
+\DeclareOption { cs-break-off }
+  { \bool_gset_false:N \g_@@_cs_break_bool }
+\DeclareOption { cs-break-nohyphen }
+  { \PassOptionsToPackage{nohyphen}{underscore} }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \DeclareOption* { \PassOptionsToClass { \CurrentOption } { article } }
 \ExecuteOptions { full, kernel, nocheck, nochecktest, lm-default }
 \PassOptionsToClass { a4paper } { article }
@@ -1460,9 +1474,9 @@ and all files in that bundle must be distributed together.
     pifont,
     textcomp,
     trace,
-    underscore,
     csquotes,
     fancyvrb,
+    underscore,
     verbatim
   }
 \raggedbottom
@@ -1935,7 +1949,10 @@ and all files in that bundle must be distributed together.
       }
 %    \end{macrocode}
 % \paragraph{Typesetting}
-% Note the replacement for the underscore is to permit linebreaks (while also omitting the hyphen).
+% Note the replacement for the underscore is to permit linebreaks.
+% The \texttt{underscore} package adds the linebreak,
+% and the regex results in applying the breakable underscore only to the \emph{last}
+% of a run of underscores, and not if the underscore follows a backslash.
 %    \begin{macrocode}
     \mode_if_math:T { \mbox }
       {
@@ -1943,8 +1960,13 @@ and all files in that bundle must be distributed together.
         \@@_if_almost_str:VT \l_@@_cmd_tl
           {
             \tl_set:Nx \l_@@_cmd_tl { \tl_to_str:N \l_@@_cmd_tl }
-            \tl_replace_all:Non \l_@@_cmd_tl
-              { \token_to_str:N _ } { \textunderscore\discretionary{}{}{} }
+            \bool_if:NT \g_@@_cs_break_bool
+              {
+                \regex_replace_all:nnN
+                  {([^\\])_([^\_])}
+                  {\1\c{BreakableUnderscore}\2}
+                  \l_@@_cmd_tl
+              }
           }
         \tl_replace_all:Nnn \l_@@_cmd_tl { ~ } { \@xobeysp }
         \l_@@_cmd_tl





More information about the latex3-commits mailing list