Skip to content

Commit

Permalink
Ignore weird par nodes in LMTX
Browse files Browse the repository at this point in the history
Fixes #45, for real this time. (73445ca fixed lua-widow-control with
LuaMetaTeX in general, but it didn't actually fix _this_ issue. Whoops.)
  • Loading branch information
gucci-on-fleek committed May 9, 2024
1 parent 431438a commit 7839056
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/lua-widow-control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ local hlist_id = id_from_name("hlist")
local line_subid = 1
local mark_id = id_from_name("mark")
local par_id = id_from_name("par") or id_from_name("local_par")
local par_subids = table.swapped(node.subtypes("par") or {})
local parfill_subids = {
parfillleftskip = 17,
parfillrightskip = 16,
Expand Down Expand Up @@ -560,13 +561,16 @@ end
--- @param head node The pre-broken paragraph
--- @return node head The unmodified `head` argument
function lwc.save_paragraphs(head)
if (head.id ~= par_id and context) or -- Make sure that `head` is a paragraph
if (context and head.id ~= par_id) or -- Make sure that `head` is a paragraph
status.output_active or -- Don't run during the output routine
tex.nest.ptr > 1 -- Don't run inside boxes
tex.nest.ptr > 1 or -- Don't run inside boxes
(lmtx and not ( -- Check for weird `par` nodes
head.subtype == par_subids.vmodepar or
head.subtype == par_subids.hmodepar
))
then
return head
end

-- Prevent the "underfull hbox" warnings when we store a potential paragraph
local renable_box_warnings
if (context or optex) or
Expand Down
39 changes: 39 additions & 0 deletions tests/context/description.lvtext
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
% lua-widow-control
% https://github.com/gucci-on-fleek/lua-widow-control
% SPDX-License-Identifier: MPL-2.0+
% SPDX-FileCopyrightText: 2024 Max Chernoff

% See https://github.com/gucci-on-fleek/lua-widow-control/issues/45

\usemodule[lua-widow-control]
\setuplwc[showcolours=start]

\setuppapersize[A6]

\setupindenting[yes, 3em]

\definefontfeature[default][default][expansion=quality,protrusion=quality]

\usetypescript[modern-base]
\setupbodyfont[reset,modern]

\setupalign[hz, hanging, verytolerant]

\definedescription[concept]

\setupdescription[concept][
indenting=yes,
width=fit,
]

\startdocument
\samplefile{knuth}

\dorecurse{3}{
\startconcept{Concept}
\dorecurse{8}{
Filler \dorecurse{15}{ filler}.\par
}
\stopconcept
}
\stopdocument
161 changes: 161 additions & 0 deletions tests/context/description.mkiv.tltext

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

161 changes: 161 additions & 0 deletions tests/context/description.tltext

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7839056

Please sign in to comment.