summaryrefslogtreecommitdiff
path: root/macros/luatex/generic
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-12-16 03:01:13 +0000
committerNorbert Preining <norbert@preining.info>2021-12-16 03:01:13 +0000
commit16b22a983bc0f05cbbb201a6e0f5cbbfc3c8fffb (patch)
tree09f27480427360daa44bee043154b5d9580efa33 /macros/luatex/generic
parent0efaa39c6d0b17b58df9a68ae1319ea20aaabc28 (diff)
CTAN sync 202112160301
Diffstat (limited to 'macros/luatex/generic')
-rw-r--r--macros/luatex/generic/lua-widow-control/README.md2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.lua10
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.pdfbin313873 -> 314157 bytes
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.sty2
-rw-r--r--macros/luatex/generic/lua-widow-control/lua-widow-control.tex2
-rw-r--r--macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl12
-rw-r--r--macros/luatex/generic/lua-widow-control/lwc-documentation.tex2
-rw-r--r--macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl4
-rw-r--r--macros/luatex/generic/penlight/penlight.pdfbin29537 -> 29642 bytes
-rw-r--r--macros/luatex/generic/penlight/penlight.sty4
-rw-r--r--macros/luatex/generic/penlight/penlight.tex2
-rw-r--r--macros/luatex/generic/penlight/penlightextras.lua128
12 files changed, 67 insertions, 101 deletions
diff --git a/macros/luatex/generic/lua-widow-control/README.md b/macros/luatex/generic/lua-widow-control/README.md
index 71a4d67f46..6e467d96ff 100644
--- a/macros/luatex/generic/lua-widow-control/README.md
+++ b/macros/luatex/generic/lua-widow-control/README.md
@@ -42,4 +42,4 @@ Lua-widow-control is licensed under the [_Mozilla Public License_, version 2.0](
Please note that a compiled document is absolutely **not** considered to be an "Executable Form" as defined by the MPL. The use of lua-widow-control in a document does not place **any** obligations on the document's author or distributors. The MPL and CC-BY-SA licenses **only** apply to you if you distribute the lua-widow-control source code or documentation.
---
-_v1.1.1 (2021-11-26)_ <!--%%version %%date-->
+_v1.1.2 (2021-12-14)_ <!--%%version %%date-->
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua b/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
index 587288e1da..dd488f3bd2 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.lua
@@ -60,12 +60,13 @@ assert(lwc.context or luatexbase, [[
if lwc.context then
lwc.warning = logs.reporter("module", lwc.name)
lwc.attribute = attributes.public(lwc.name)
- lwc.contrib_head = 'contribute_head' -- For \LuaMetaTeX{}
+ lwc.contrib_head = 'contributehead' -- For \LuaMetaTeX{}
+ lwc.stretch_order = "stretchorder"
elseif lwc.plain or lwc.latex then
luatexbase.provides_module {
name = lwc.name,
- date = "2021/11/26", --%%date
- version = "1.1.1", --%%version
+ date = "2021/12/14", --%%date
+ version = "1.1.2", --%%version
description = [[
This module provides a LuaTeX-based solution to prevent
@@ -77,6 +78,7 @@ elseif lwc.plain or lwc.latex then
lwc.warning = function(str) luatexbase.module_warning(lwc.name, str) end
lwc.attribute = luatexbase.new_attribute(lwc.name)
lwc.contrib_head = 'contrib_head' -- For \LuaTeX{}
+ lwc.stretch_order = "stretch_order"
else -- uh oh
error [[
Unsupported format.
@@ -167,7 +169,7 @@ function lwc.save_paragraphs(head)
-- Prevent ultra-short last lines (\TeX{}Book p. 104), except with narrow columns
local parfillskip = last(new_head)
if parfillskip.id == glue_id and tex.hsize > min_col_width then
- parfillskip.stretch_order = 0
+ parfillskip[lwc.stretch_order] = 0
parfillskip.stretch = 0.8 * tex.hsize -- Last line must be at least 20% long
end
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf b/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
index c0107a6278..d8c7777e88 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.pdf
Binary files differ
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
index ab6e6ffbc1..0b4826dc5e 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.sty
@@ -5,7 +5,7 @@
\NeedsTeXFormat{LaTeX2e}[2015/01/01] % Formats built after 2015 include \LuaTeX{}Base
\ProvidesPackage{lua-widow-control}%
- [2021/11/26 v1.1.1] %%version %%date
+ [2021/12/14 v1.1.2] %%version %%date
\setlength{\clubpenalty}{1}
\setlength{\widowpenalty}{1}
diff --git a/macros/luatex/generic/lua-widow-control/lua-widow-control.tex b/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
index cba8ecfe39..715652186e 100644
--- a/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
+++ b/macros/luatex/generic/lua-widow-control/lua-widow-control.tex
@@ -3,7 +3,7 @@
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2021 Max Chernoff
-\wlog{lua-widow-control v1.1.1} %%version
+\wlog{lua-widow-control v1.1.2} %%version
\input ltluatex % \LuaTeX{}Base
diff --git a/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl b/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl
index 05d9d930f9..a4489b2e70 100644
--- a/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl
+++ b/macros/luatex/generic/lua-widow-control/lwc-documentation.mkxl
@@ -28,6 +28,7 @@ fonts.handlers.otf.addfeature {
onum=yes,
script=latn,
emdash_kern=yes,
+ trep=yes,
]
\setupalign[hz, hanging]
@@ -171,6 +172,7 @@ setbounds currentpicture to boundingbox OverlayBox;
]
% TOC
+\def\secondleveltoc{subsection}
\starttexdefinition protected SectionTOCcommand #1#2#3
\startcurrentlistentrywrapper % Make the whole line a link
\midaligned{ % Have the title and page number "glued" to the middle
@@ -190,7 +192,7 @@ setbounds currentpicture to boundingbox OverlayBox;
toffset=-\lineheight,
]{
\global\firstsubsectiontrue
- \placelist[subsection][criterium=local]
+ \placelist[\secondleveltoc][criterium=local]
}}
\iffirstsubsection
\blank[quarterline] % No subsections here
@@ -289,8 +291,12 @@ interfaces.implement {
\blackrule[depth=-0.25\baselineskip, height=\dimexpr0.25\baselineskip + 0.4pt, width=8em]
\par
- \strippedurl{\documentvariable{ctan}}
- \strippedurl{\documentvariable{github}}
+ \doifdocumentvariable{ctan}{
+ \strippedurl{\documentvariable{ctan}}
+ }
+ \doifdocumentvariable{github}{
+ \strippedurl{\documentvariable{github}}
+ }
\blank[big]
\noindentation
diff --git a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
index a49ab00a53..689fcda643 100644
--- a/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
+++ b/macros/luatex/generic/lua-widow-control/lwc-documentation.tex
@@ -37,7 +37,7 @@
\startdocument[
title=lua-widow-control,
author=Max Chernoff,
- version=1.1.1, %%version
+ version=1.1.2, %%version
github=https://github.com/gucci-on-fleek/lua-widow-control,
ctan=https://www.ctan.org/pkg/lua-widow-control,
]
diff --git a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
index 78bdf1fc34..90ede02913 100644
--- a/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
+++ b/macros/luatex/generic/lua-widow-control/t-lua-widow-control.mkxl
@@ -1,10 +1,10 @@
%D \module
%D [ file=t-lua-widow-control,
-%D version=1.1.1, %%version
+%D version=1.1.2, %%version
%D title=lua-widow-control,
%D subtitle=\ConTeXt module for lua-widow-control,
%D author=Max Chernoff,
-%D date=2021-11-26, %%date
+%D date=2021-12-14, %%date
%D copyright=Max Chernoff,
%D license=MPL-2.0+,
%D url=https://github.com/gucci-on-fleek/lua-widow-control]
diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf
index 8d07293e47..1edb8bf2b5 100644
--- a/macros/luatex/generic/penlight/penlight.pdf
+++ b/macros/luatex/generic/penlight/penlight.pdf
Binary files differ
diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty
index 1f1fccc042..9f0ead874f 100644
--- a/macros/luatex/generic/penlight/penlight.sty
+++ b/macros/luatex/generic/penlight/penlight.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,7 +22,7 @@
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{penlight}[2021-11-07]
+\ProvidesPackage{penlight}[2021-12-15]
\RequirePackage{luacode}
diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex
index 68b8f1bb40..79a5d08589 100644
--- a/macros/luatex/generic/penlight/penlight.tex
+++ b/macros/luatex/generic/penlight/penlight.tex
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-11-07
+% 2021-12-15
% Copyright (C) 2021 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua
index 13d0ab5817..3479eb3fa0 100644
--- a/macros/luatex/generic/penlight/penlightextras.lua
+++ b/macros/luatex/generic/penlight/penlightextras.lua
@@ -20,7 +20,6 @@ function help_wrt(s1, s2) -- helpful printing, makes it easy to debug, s1 is obj
wrt('\n^^^^^\n')
end
-
function prt_array2d(t)
for _, r in ipairs(t) do
local s = ''
@@ -83,7 +82,7 @@ end
-- -- -- -- functions below extend the array2d module
-local function map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr
+function pl.array2d.map_slice1(func, L, i1, i2) -- map a function to a slice of an array, can use PlcExpr
i2 = i2 or i1
local len = #L
i1 = check_index(i1, len)
@@ -95,7 +94,7 @@ local function map_slice1(func, L, i1, i2) -- map a function to a slice of an ar
return L
end
-local function map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix
+function pl.array2d.map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice of a Matrix
i1, j1, i2, j2 = check_slice(M, i1, j1, i2, j2)
--for i,j in array2d.iter(M, true, i1, j1, i2, j2) do --todo this did not work, penlight may have fixed this
func = check_func(func)
@@ -107,12 +106,12 @@ local function map_slice2(func, M, i1, j1, i2, j2) -- map a function to a slice
return M
end
-local function map_columns(func, M, j1, j2) -- map function to columns of matrix
+function pl.array2d.map_columns(func, M, j1, j2) -- map function to columns of matrix
j2 = j2 or j1
return map_slice2(func, M, 1, j1, -1, j2)
end
-local function map_rows(func, M, i1, i2) -- map function to rows of matrix
+function pl.array2d.map_rows(func, M, i1, i2) -- map function to rows of matrix
i2 = i2 or i1
return map_slice2(func, M, i1, 1, i2, -1)
end
@@ -120,7 +119,7 @@ end
-- -- -- -- -- -- -- --
-function sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element
+function pl.array2d.sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele is column, ie sort on which element
M_new = {}
for row in pl.seq.sort(M, comp_2ele_func(op, ele)) do
M_new[#M_new+1] = row
@@ -128,13 +127,13 @@ function sortOP(M, op, ele) -- sort a 2d array based on operator criteria, ele i
return M_new
end
-local function like(M1, v)
+function pl.array2d.like(M1, v)
v = v or 0
r, c = pl.array2d.size(M1)
return pl.array2d.new(r,c,v)
end
-local function from_table(t) -- turns a labelled table to a 2d, label-free array
+function pl.array2d.from_table(t) -- turns a labelled table to a 2d, label-free array
t_new = {}
for k, v in pairs(t) do
if type(v) == 'table' then
@@ -150,7 +149,7 @@ local function from_table(t) -- turns a labelled table to a 2d, label-free array
return t_new
end
-local function toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
+function pl.array2d.toTeX(M, EL) --puts & between columns, can choose to end line with \\ if EL is true (end-line)
EL = EL or false
if EL then EL = '\\\\' else EL = '' end
return pl.array2d.reduce2(_1..EL.._2, _1..'&'.._2, M)..EL
@@ -158,31 +157,41 @@ end
-- -- -- -- -- -- --
--- add to array2d module
-pl.array2d['map_columns'] = map_columns
-pl.array2d['map_rows'] = map_rows
-pl.array2d['map_slice2'] = map_slice2
-pl.array2d['map_slice1'] = map_slice1
-pl.array2d['from_table'] = from_table
-pl.array2d['toTeX'] = toTeX
-pl.array2d['sortOP'] = sortOP
-pl.array2d['like'] = like
-- -- -- -- -- -- -- -- -- -- -- -- functions below extend the operator module
-local function strgt(a,b) return tostring(a) > tostring(b) end
-local function strlt(a,b) return tostring(a) < tostring(b) end
-pl.operator['strgt'] = strgt
-pl.operator['strlt'] = strlt
+function pl.operator.strgt(a,b) return tostring(a) > tostring(b) end
+function pl.operator.strlt(a,b) return tostring(a) < tostring(b) end
+
+
+-- -- -- -- string stuff
+local lpeg = require"lpeg"
+local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V
+local number = P{"number",
+ number = (V"int" * V"frac"^-1 * V"exp"^-1) / tonumber,
+ int = V"sign"^-1 * (R"19" * V"digits" + V"digit"),
+ digits = V"digit" * V"digits" + V"digit",
+ digit = R"09",
+ sign = S"+-",
+ frac = P"." * V"digits",
+ exp = S"eE" * V"sign"^-1 * V"digits",
+ }
-local function gextract(s, pat) --extract a pattern from string, returns both
+local mt = getmetatable("") -- register functions with str
+
+
+function mt.__index.gnum(s)
+ return number:match(s)
+end
+
+function mt.__index.gextract(s, pat) --extract a pattern from string, returns both
local s_extr = ''
local s_rem = s
for e in s:gmatch(pat) do
@@ -192,7 +201,7 @@ local function gextract(s, pat) --extract a pattern from string, returns both
return s_extr, s_rem
end
-local function gfirst(s, t) -- get the first pattern found from a table of pattern
+function mt.__index.gfirst(s, t) -- get the first pattern found from a table of pattern
for _, pat in pairs(t) do
if string.find(s, pat) then
return pat
@@ -200,7 +209,7 @@ local function gfirst(s, t) -- get the first pattern found from a table of patte
end
end
-local function appif(S, W, B, O) --append W ord to S tring if B oolean true, otherwise O ther
+function mt.__index.appif(S, W, B, O) --append W ord to S tring if B oolean true, otherwise O ther
--append Word to String
if B then --if b is true
S = S .. W
@@ -211,12 +220,10 @@ local function appif(S, W, B, O) --append W ord to S tring if B oolean true, oth
return S
end
-local mt = getmetatable("") -- register functions with str
-mt.__index["gextract"] = gextract
-mt.__index["gfirst"] = gfirst
-mt.__index["app_if"] = appif
+-- -- -- -- -- math stuffs
+
function mod(a, b) -- math modulo, return remainder only
return a - (math.floor(a/b)*b)
end
@@ -226,9 +233,11 @@ function mod2(a) -- math modulo 2
end
function hasval(x) -- if something has value
- if (x == nil) or (x == false) or (x == 0) or (x == '') then
+ if (type(x) == 'function') then
+ return true
+ elseif (x == nil) or (x == false) or (x == 0) or (x == '') then
return false
- elseif (type(x) ~= 'number') or (type(x) ~= 'string') then
+ elseif (type(x) ~= 'boolean') and (type(x) ~= 'number') and (type(x) ~= 'string') then
if #x == 0 then
return false
else
@@ -241,59 +250,6 @@ end
--- testing here
-____zzz__ = [[
-function hasStrKey(T)
- --checks if a Table contains a string-type key
- local hasaStrKey = false
- for k, v in pairs(T) do --look through table pairs
- if type(k) == "string" then --if any string found, return true
- hasaStrKey = true
- break
- end
- end
- return hasaStrKey
-end
-
-
-function any()
- --todo go through table or list of args and return true of anything is something
-end
-
-function all()
- --todo go through table or list of args and return true of anything is something
-end
-
-
- --elseif x == {} then
- -- return false
-
-n = nil
-b = false
-z = 0
-e = ''
-t = {}
-
---s = 'a'
---n = 1
-
-
-if is(nil) then
- print('TRUE')
-else
- print('FALSE')
-end
-
---print({}=={})
---print(0.0==0)
-
-
-]]
-
-
-
-
-
@@ -343,8 +299,10 @@ function reset_bkt_cnt(n)
end
function add_bkt_cnt(n)
+ -- add open bracket n times, returns brackets
n = n or 1
_NumBkts = _NumBkts + n
+ return ('{'):rep(n)
end
function close_bkt_cnt()
@@ -361,7 +319,7 @@ end
--definition helpers -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--- todo add this
+-- todo add and improve this
local function defcmd_nest(cs) -- for option if you'd like your commands under a parent ex. \csparent{var}
tex.print('\\gdef\\'..cs..'#1{\\csname '..var..'--#1--\\endcsname}')