diff --git a/classes/base.lua b/classes/base.lua index ac6405bc6..349395919 100644 --- a/classes/base.lua +++ b/classes/base.lua @@ -696,16 +696,18 @@ end -- WARNING: not called as class method function class.endPar (typesetter) + -- If we're already explicitly out of hmode don't do anything special in the way of skips or indents. Assume the user + -- has handled that how they want, e.g. with a skip. + local queue = typesetter.state.outputQueue + local last_vbox = queue and queue[#queue] + local last_is_vglue = last_vbox and last_vbox.is_vglue + local last_is_vpenalty = last_vbox and last_vbox.is_penalty + if typesetter:vmode() and (last_is_vglue or last_is_vpenalty) then + return + end SILE.settings:set("current.parindent", nil) + typesetter:leaveHmode() typesetter:pushVglue(SILE.settings:get("document.parskip")) - if SILE.settings:get("current.hangIndent") then - SILE.settings:set("current.hangIndent", nil) - SILE.settings:set("linebreak.hangIndent", nil) - end - if SILE.settings:get("current.hangAfter") then - SILE.settings:set("current.hangAfter", nil) - SILE.settings:set("linebreak.hangAfter", nil) - end end function class:newPage () @@ -725,6 +727,7 @@ end function class:finish () SILE.inputter:postamble() + SILE.typesetter:endline() SILE.call("vfill") while not SILE.typesetter:isQueueEmpty() do SILE.call("supereject") diff --git a/classes/book.lua b/classes/book.lua index 4388d1ed1..4fe4a5ea2 100644 --- a/classes/book.lua +++ b/classes/book.lua @@ -166,6 +166,7 @@ function class:registerCommands () if SILE.Commands[postcmd .. ":" .. lang] then postcmd = postcmd .. ":" .. lang end + SILE.call("nofoliothispage") SILE.call(postcmd) SILE.call("book:chapterfont", {}, content) SILE.call("left-running-head", {}, function () @@ -173,8 +174,11 @@ function class:registerCommands () SILE.call("book:left-running-head-font", {}, content) end) end) + SILE.call("novbreak") + SILE.call("par") + SILE.call("novbreak") SILE.call("bigskip") - SILE.call("nofoliothispage") + SILE.call("novbreak") -- English typography (notably) expects the first paragraph under a section -- not to be indented. Frenchies, don't use this class :) SILE.call("noindent") @@ -215,12 +219,13 @@ function class:registerCommands () end) end SILE.call("novbreak") + SILE.call("par") + SILE.call("novbreak") SILE.call("bigskip") SILE.call("novbreak") -- English typography (notably) expects the first paragraph under a section -- not to be indented. Frenchies, don't use this class :) SILE.call("noindent") - SILE.typesetter:inhibitLeading() end, "Begin a new section") self:registerCommand("subsection", function (options, content) @@ -242,14 +247,14 @@ function class:registerCommands () SILE.call(postcmd) SILE.process(content) end) - SILE.typesetter:leaveHmode() + SILE.call("novbreak") + SILE.call("par") SILE.call("novbreak") SILE.call("medskip") SILE.call("novbreak") -- English typography (notably) expects the first paragraph under a section -- not to be indented. Frenchies, don't use this class :) SILE.call("noindent") - SILE.typesetter:inhibitLeading() end, "Begin a new subsection") self:registerCommand("book:chapterfont", function (_, content) diff --git a/classes/plain.lua b/classes/plain.lua index 08fcd337d..149694153 100644 --- a/classes/plain.lua +++ b/classes/plain.lua @@ -78,8 +78,16 @@ function class:registerCommands () self:registerCommand("noindent", function (_, content) if #SILE.typesetter.state.nodes ~= 0 then - SU.warn( - "\\noindent called after nodes already received in a paragraph, the setting will have no effect because the parindent (if any) has already been output" + SU.warn([[\noindent was called after paragraph content has already been procesed. + + This will not result in avoiding the current paragraph being indented. + This function must be called before any content belonging to the + paragraph is processed. If the intent was to suppress indentation of a + following paragraph, first explicitly close the current paragraph. From + an input document this is typically done with an empty line between + paragraphs, but calling the \par command explicitly or from Lua code + running SILE.call("par") will end the current paragraph. +]] ) end SILE.settings:set("current.parindent", SILE.types.node.glue()) diff --git a/tests/bug-1647.sil b/tests/bug-1647.sil index 0a71bbbed..58ad26447 100644 --- a/tests/bug-1647.sil +++ b/tests/bug-1647.sil @@ -8,6 +8,7 @@ This paragraph is at the page top. This paragraph has a big parskip before it. + \vfill This paragraph must be at the page bottom. \par diff --git a/typesetters/base.lua b/typesetters/base.lua index 0d3f0201c..f6efd0dc3 100644 --- a/typesetters/base.lua +++ b/typesetters/base.lua @@ -349,8 +349,16 @@ function typesetter:initline () end function typesetter:endline () - self:leaveHmode() SILE.documentState.documentClass.endPar(self) + self:leaveHmode() + if SILE.settings:get("current.hangIndent") then + SILE.settings:set("current.hangIndent", nil) + SILE.settings:set("linebreak.hangIndent", nil) + end + if SILE.settings:get("current.hangAfter") then + SILE.settings:set("current.hangAfter", nil) + SILE.settings:set("linebreak.hangAfter", nil) + end end -- Just compute once, to avoid unicode characters in source code.