diff options
author | Karl Berry <karl@freefriends.org> | 2022-06-01 20:08:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-06-01 20:08:41 +0000 |
commit | aa1bfca634b519a014b6a74f78dafa9609a545a8 (patch) | |
tree | 45abd300f4b737d785e23e13dfa418b58d1d797e /Master/texmf-dist/tex | |
parent | 406f893ecc900db02d81719fea8fe374668d8994 (diff) |
lua-ul (1jun22)
git-svn-id: svn://tug.org/texlive/trunk@63469 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
5 files changed, 236 insertions, 91 deletions
diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty b/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty index f3a2136a6a6..bcd35b8c4e5 100644 --- a/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty +++ b/Master/texmf-dist/tex/lualatex/lua-ul/docstrip-luacode.sty @@ -1,4 +1,4 @@ -%% Copyright (C) 2020-2021 by Marcel Krueger +%% Copyright (C) 2020-2022 by Marcel Krueger %% %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either @@ -14,6 +14,8 @@ \ProvidesPackage {docstrip-luacode} [2021/05/12 v0.1.4 Directly execute Lua code from DocStrip files] +\RequirePackage{iftex} +\RequireLuaTeX \expanded{% \def\noexpand\docstrip@luacode@argscanner#1\directlua{ tex.sprint(\the\catcodetable@string, "\string\\end{docstrip-luacode}") diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua index bbed3b6b47b..2b0f0720553 100644 --- a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua +++ b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul-patches-preserve-attr.lua @@ -6,7 +6,7 @@ -- -- lua-ul.dtx (with options: `preserve-attr') -- --- Copyright (C) 2020-2021 by Marcel Krueger +-- Copyright (C) 2020-2022 by Marcel Krueger -- -- This file may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua index 3d4350fc205..db4acae9659 100644 --- a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua +++ b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.lua @@ -6,7 +6,7 @@ -- -- lua-ul.dtx (with options: `luacode') -- --- Copyright (C) 2020-2021 by Marcel Krueger +-- Copyright (C) 2020-2022 by Marcel Krueger -- -- This file may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty index 3f9c6571f74..562beef0f9e 100644 --- a/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty +++ b/Master/texmf-dist/tex/lualatex/lua-ul/lua-ul.sty @@ -6,7 +6,7 @@ %% %% lua-ul.dtx (with options: `package') %% -%% Copyright (C) 2020-2021 by Marcel Krueger +%% Copyright (C) 2020-2022 by Marcel Krueger %% %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either @@ -18,105 +18,248 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage +\ProvidesExplPackage {lua-ul} - [2021/05/12 v0.1.4 Underlining and related functionality for LuaTeX] - -\ifx\directlua\undefined - \PackageError{lua-ul}{LuaLaTeX required}% - {Lua-UL requires LuaLaTeX. - Maybe you forgot to switch the engine in your editor?} -\fi -\directlua{require'lua-ul'} -\RequirePackage{xparse} -\newif\ifluaul@predefined -\newif\ifluaul@soulnames -\luaul@predefinedtrue -\DeclareOption{minimal}{\luaul@predefinedfalse} -\DeclareOption{soul}{\luaul@soulnamestrue} + {2022-05-31}{0.2.0}{Underlining and related functionality for LuaTeX} +\msg_new:nnnn {lua-ul} {luatex-required} {LuaLaTeX~required} { + Lua-UL~requires~LuaLaTeX.~ + Maybe~you~forgot~to~switch~the~engine~in~your~editor? +} +\msg_new:nnnn {lua-ul} {luacolor-required} { + Color~support~in~lua-ul~requires~luacolor. +}{ + This~error~can~be~fixed~by~adding~\token_to_str:N \usepackage{luacolor}~in~your~preamble. +} +\sys_if_engine_luatex:F { + \msg_error:nn {lua-ul} {luatex-required} +} +\lua_load_module:n {lua-ul} +\bool_new:N \l__luaul_predefined_bool +\bool_new:N \l__luaul_soulnames_bool +\bool_set_true:N \l__luaul_predefined_bool +\DeclareOption {minimal} { \bool_set_false:N \l__luaul_predefined_bool } +\DeclareOption {soul} { \bool_set_true:N \l__luaul_soulnames_bool } \ProcessOptions\relax -\protected\def\luaul@maybedefineuse#1#2{% - \unless\ifcsname#1\endcsname - \expandafter\xdef\csname#1\endcsname{#2}% - \fi - \csname#1\endcsname +\cs_new_protected:Npn \__luaul_maybe_define_use:Nx #1#2 { + \cs_if_free:NT #1 { + \cs_gset:Npx #1 {#2} + } + #1 } - \newcommand\luaul@defaultcontext{% - \number\dimexpr1ex - @\unless\ifx\undefined\LuaCol@Attribute - \the\LuaCol@Attribute - \fi - } -\NewDocumentCommand\newunderlinetype - { E{*}{{}} m O{\luaul@defaultcontext} m }{% - \newcommand#2{}% "Reserve" the name - \protected\def#2{% - \expandafter\luaul@maybedefineuse - \expanded{{\csstring#2@@#3}}% - {\LuaULSetUnderline - \LuaULNewUnderlineType#1{#4\hskip0pt}% - }}% +\cs_generate_variant:Nn \__luaul_maybe_define_use:Nx {c} +\cs_new:Npn \__luaul_default_context: { + \dim_to_decimal_in_sp:n {1ex} + @ + \cs_if_exist:NT \LuaCol@Attribute { + \int_use:N \LuaCol@Attribute + } } -\ifluaul@predefined - \newcommand\luaul@highlight@color{yellow} - \def\luaul@@setcolor\xcolor@#1#2{} - \newcommand\luaul@setcolor[1]{% - \ifx\XC@getcolor\undefined - \def\luaul@currentcolor{#1}% - \else - \begingroup - \XC@getcolor{#1}\luaul@tmpcolor - \expanded{\endgroup - \def\noexpand\luaul@currentcolor{% - \expandafter\luaul@@setcolor\luaul@tmpcolor}}% - \fi - } - \newcommand\luaul@applycolor{% - \ifx\XC@getcolor\undefined - \color{\luaul@currentcolor}% - \else - \expandafter\XC@undeclaredcolor\luaul@currentcolor - \fi - } -\NewDocumentCommand\LuaULSetHighLightColor{om}{% - \edef\luaul@highlight@color{\IfValueTF{#1}{[#1]{#2}}{#2}}% +\NewDocumentCommand \newunderlinetype + { E{*}{{}} m O{\__luaul_default_context:} m } { + \cs_new_protected:Npn #2 { + \__luaul_maybe_define_use:cx { + __luaul_set_underline_ \cs_to_str:N #2 _ #3 : + } { + \LuaULSetUnderline + \LuaULNewUnderlineType #1 { #4 \hskip 0pt } + } + } } - \newunderlinetype\@underLine{% - \leaders\vrule height -.65ex depth .75ex + +\bool_if:NT \l__luaul_predefined_bool { + \msg_new:nnnn {lua-ul} {height-inconsistent} {Specified~height~is~inconsistent~with~specified~top~and~bottom}{} + \msg_new:nnnn {lua-ul} {deprecated} {Used~deprecated~command~`\token_to_str:N #1'.~Please~replace~this~with~`\token_to_str:N #2`.}{} + \cs_new:Npn \__luaul_deprecated:NN #1#2 { + \cs_new_protected:Npn #1 { + \msg_warning:nnnn {lua-ul} {deprecated} {#1} {#2} + \cs_gset_eq:NN #1 #2 + #1 + } + } + \tl_new:N \l__luaul_current_color_tl + \cs_new:Npn \__luaul_set_color_strip:w \xcolor@ #1#2 {} + \cs_new_protected:Npn \luaul_set_color:n #1 { + \cs_if_free:NTF \XC@getcolor { + \tl_set:Nn \l__luaul_current_color_tl {#1} + } { + \group_begin: + \XC@getcolor {#1} \l_tmpa_tl + \use:e { \group_end: + \tl_set:Nn \exp_not:N \l__luaul_current_color_tl { + \exp_after:wN \__luaul_set_color_strip:w \l_tmpa_tl + } + } + } + } + \__luaul_deprecated:NN \luaul@setcolor \luaul_set_color:n + \cs_new_protected:Npn \luaul_apply_color: { + \IfPackageLoadedTF {luacolor} { + \cs_if_free:NTF \XC@getcolor { + \color {\l__luaul_current_color_tl} + }{ + \exp_after:wN \XC@undeclaredcolor \l__luaul_current_color_tl + } + }{ + \msg_error:nn {lua-ul} {luacolor-required} + } + } + \__luaul_deprecated:NN \luaul@applycolor \luaul_apply_color: + \cs_new:Npn \luaul_context_color: { + \l__luaul_current_color_tl + } + \cs_new:Npn \__luaul_default_colored_context: { + \dim_to_decimal_in_sp:n {1ex} + @ + \luaul_context_color: + } + \tl_new:N \l__luaul_highlight_color_tl + \tl_set:Nn \l__luaul_highlight_color_tl {yellow} + \NewDocumentCommand \LuaULSetHighLightColor {om} { + \tl_set:Nx \l__luaul_highlight_color_tl { + \IfValueTF {#1} { + [#1]{#2} + }{ + #2 + } + } } - \NewDocumentCommand\underLine{+m}{{\@underLine#1}} - \newunderlinetype\@strikeThrough{% - \leaders\vrule height .55ex depth -.45ex + \dim_new:N \l__luaul_top_dim + \dim_new:N \l__luaul_bottom_dim + \dim_new:N \l__luaul_height_dim + \bool_new:N \l__luaul_top_set_bool + \bool_new:N \l__luaul_bottom_set_bool + \bool_new:N \l__luaul_height_set_bool + \bool_new:N \l__luaul_color_set_bool + + \keys_define:nn {luaul / generic} { + top .code:n = { + \bool_set_true:N \l__luaul_top_set_bool + \dim_set:Nn \l__luaul_top_dim {#1} + }, + bottom .code:n = { + \bool_set_true:N \l__luaul_bottom_set_bool + \dim_set:Nn \l__luaul_bottom_dim {(#1)*-1} + }, + height .code:n = { + \bool_set_true:N \l__luaul_height_set_bool + \dim_set:Nn \l__luaul_height_dim {#1} + }, + color .code:n = { + \bool_set_true:N \l__luaul_color_set_bool + \luaul_set_color:n {#1} + }, + textcolor .code:n = { + \bool_set_false:N \l__luaul_color_set_bool + }, + textcolor .value_forbidden:n = true, } - \newunderlinetype\colored@strikeThrough[\number\dimexpr1ex@% - \luaul@currentcolor]{% - \luaul@applycolor + + \cs_new:Npn \__luaul_parse_generic_keys:n #1 { + \bool_set_false:N \l__luaul_top_set_bool + \bool_set_false:N \l__luaul_bottom_set_bool + \bool_set_false:N \l__luaul_height_set_bool + + \keys_set:nn {luaul / generic} {#1} + + \bool_if:NTF \l__luaul_bottom_set_bool { + \bool_if:NTF \l__luaul_top_set_bool { + \bool_if:NTF \l__luaul_height_set_bool { + \dim_compare:nNnF { \l__luaul_top_dim + \l__luaul_bottom_dim } = {\l__luaul_height_dim} { + \msg_error:nn {lua-ul} {height-inconsistent} + } + } { + \dim_set:Nn \l__luaul_height_dim { \l__luaul_top_dim + \l__luaul_bottom_dim } + } + } { + \dim_set:Nn \l__luaul_top_dim { \l__luaul_height_dim - \l__luaul_bottom_dim } + } + } { + \dim_set:Nn \l__luaul_bottom_dim { \l__luaul_height_dim - \l__luaul_top_dim } + } + } + + \newunderlinetype \@@underLine [ + \dim_to_decimal_in_sp:n { \l__luaul_top_dim } + @ + \dim_to_decimal_in_sp:n { \l__luaul_bottom_dim } + @ + \bool_if:NTF \l__luaul_color_set_bool { + colored @ \luaul_context_color: + } { + \cs_if_exist:NT \LuaCol@Attribute { + \int_use:N \LuaCol@Attribute + } + } + ] { + \bool_if:NT \l__luaul_color_set_bool { + \luaul_apply_color: + } + \leaders\vrule height \l__luaul_top_dim depth \l__luaul_bottom_dim + } + \newunderlinetype \@basicUnderLine { + \leaders \vrule height -.65ex depth .75ex + } + + \NewDocumentCommand \@underLine {o} { + \IfValueTF {#1} { + \__luaul_parse_generic_keys:n { + top = -.65ex, + bottom = -.75ex, + } + \__luaul_parse_generic_keys:n { + #1 + } + \@@underLine + } { + \@basicUnderLine + } + } + \NewDocumentCommand \underLine {o +m} { + \group_begin: + \@underLine [#1] #2 + \group_end: + } + + \newunderlinetype \@@strikeThrough { + \leaders \vrule height .55ex depth -.45ex + } + \newunderlinetype \@colored@strikeThrough [\__luaul_default_colored_context:] { + \luaul_apply_color: \leaders\vrule height .55ex depth -.45ex } - \NewDocumentCommand\strikeThrough{o+m}{{% - \IfValueTF{#1}{% - \luaul@setcolor{#1}% - \colored@strikeThrough - }\@strikeThrough% - #2% - }} + \NewDocumentCommand \@strikeThrough {o} { + \IfValueTF {#1} { + \luaul_set_color:n {#1} + \@colored@strikeThrough + } + \@@strikeThrough + } + \NewDocumentCommand \strikeThrough {o +m} { + \group_begin: + \@strikeThrough #2 + \group_end: + } - \newunderlinetype\@highLight[\number\dimexpr1ex@% - \luaul@currentcolor]{% - \luaul@applycolor + \newunderlinetype \@@highLight [\__luaul_default_colored_context:] { + \luaul_apply_color: \leaders\vrule height 1.75ex depth .75ex } - \NewDocumentCommand\highLight{O{\luaul@highlight@color}+m}{{% - \luaul@setcolor{#1}% - \@highLight#2% - }} - \ifluaul@soulnames - \let\textul\underLine \let\ul\textul - \let\textst\strikeThrough \let\st\textst - \let\texthl\highLight \let\hl\texthl - \fi -\fi + \NewDocumentCommand \@highLight {O{\l__luaul_highlight_color_tl}} { + \luaul_set_color:n {#1} + \@@highLight + } + \NewDocumentCommand \highLight {O{\l__luaul_highlight_color_tl} +m} { + \group_begin: + \@highLight [#1] #2 + \group_end: + } + \bool_if:NT \l__luaul_soulnames_bool { + \cs_new_eq:NN \textul \underLine \cs_new_eq:NN \ul \textul + \cs_new_eq:NN \textst \strikeThrough \cs_new_eq:NN \st \textst + \cs_new_eq:NN \texthl \highLight \cs_new_eq:NN \hl \texthl + } +} \ifx \reset@font \normalfont \let \reset@font \relax \DeclareRobustCommand \reset@font {% diff --git a/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua b/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua index 810247ddfea..0fdc6c4f84e 100644 --- a/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua +++ b/Master/texmf-dist/tex/lualatex/lua-ul/pre_append_to_vlist_filter.lua @@ -6,7 +6,7 @@ -- -- lua-ul.dtx (with options: `callback') -- --- Copyright (C) 2020-2021 by Marcel Krueger +-- Copyright (C) 2020-2022 by Marcel Krueger -- -- This file may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either |