Skip to content

Commit

Permalink
Merge 84aa320 into 6ad9b76
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jun 8, 2024
2 parents 6ad9b76 + 84aa320 commit 3cf4adf
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 110 deletions.
19 changes: 11 additions & 8 deletions classes/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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")
Expand Down
13 changes: 9 additions & 4 deletions classes/book.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,19 @@ 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 ()
SILE.settings:temporarily(function ()
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")
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions classes/plain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 2 additions & 4 deletions documentation/c03-input.sil
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ Space at the beginning of a line will be ignored.

Similarly, you can place a line break anywhere you like in the input file, and it won’t affect the output because SILE considers each paragraph at a time and computes the appropriate line breaks for the paragraph based on the width of the line available.
In other words, if your input file says

\begin[type=autodoc:codeblock]{raw}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
Expand All @@ -135,8 +134,7 @@ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.
\end{raw}

\noindent{}…you might not necessarily get a line break after ‘tempor’;
…you might not necessarily get a line break after ‘tempor’;
rather, you’ll get a line break wherever is most appropriate.
In the context of this document, you’ll get:

Expand All @@ -147,7 +145,7 @@ incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.\par
culpa qui officia deserunt mollit anim id est laborum.
\end{autodoc:example}
\end{font}

Expand Down
45 changes: 23 additions & 22 deletions packages/autodoc/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function package:_init (options)
base._init(self)
self:loadPackage("inputfilter")
self:loadPackage("rules")
self:loadPackage("raiselower")
if options then
pl.tablex.update(theme, options)
end
Expand Down Expand Up @@ -372,15 +373,25 @@ function package:registerCommands ()
end, "Outputs a class name.")

-- Homogenizing the appearance of blocks of code

self:registerCommand("autodoc:codeblock", function (_, content)
SILE.typesetter:leaveHmode()
SILE.settings:temporarily(function ()
-- Note: We avoid using the verbatim environment and simplify things a bit
-- (and try to better enforce novbreak points of insertion)
SILE.call("verbatim:font")
-- Rather than absolutizing 4 different values, just do it once and cache it
local ex = SILE.types.measurement("1ex"):absolute()
SILE.typesetter:leaveHmode()
local pushline = function ()
colorWrapper("note", function ()
SILE.call("novbreak")
SILE.typesetter:pushVglue(ex)
SILE.call("novbreak")
SILE.call("fullrule", { thickness = "0.5pt" })
SILE.call("novbreak")
SILE.typesetter:pushVglue(-ex)
SILE.call("novbreak")
end)
end
SILE.settings:set("typesetter.parseppattern", "\n")
SILE.settings:set("typesetter.obeyspaces", true)
SILE.settings:set("document.parindent", SILE.types.node.glue())
Expand All @@ -389,31 +400,20 @@ function package:registerCommands ()
SILE.settings:set("document.spaceskip", SILE.types.length("1spc"))
SILE.settings:set("shaper.variablespaces", false)
SILE.settings:set("document.language", "und")
SILE.typesetter:leaveHmode()
colorWrapper("codeblock", function ()
SILE.call("bigskip")
colorWrapper("note", function ()
SILE.call("autodoc:line")
end)
SILE.typesetter:pushVglue(-0.6 * ex)
SILE.call("skip", { height = ex })
pushline()
SILE.typesetter:pushVglue(SILE.settings:get("document.parskip"))
SILE.call("novbreak")
SILE.process(content)
SILE.call("novbreak")
SILE.typesetter:pushVglue(1.4 * ex)
colorWrapper("note", function ()
SILE.call("autodoc:line")
end)
SILE.call("smallskip")
SILE.typesetter:pushVglue(SILE.settings:get("document.parskip"))
pushline()
end)
SILE.typesetter:leaveHmode()
end)
end, "Outputs its content as a standardized block of code")

self:registerCommand("autodoc:line", function (_, _)
SILE.call("novbreak")
SILE.call("fullrule", { thickness = "0.5pt" })
SILE.call("novbreak")
end, "Outputs a line used for surrounding code blocks (somewhat internal)")

self:registerCommand("autodoc:example", function (_, content)
-- Loosely derived from the \examplefont command from the original SILE manual...
SILE.call("font", { family = "Cormorant Infant", size = "1.1em" }, content)
Expand All @@ -428,9 +428,9 @@ function package:registerCommands ()
local leftindent = (p.width:absolute() + ls.width:absolute()).length -- fixed part
local innerindent = SILE.types.measurement("1em"):absolute()
SILE.settings:temporarily(function ()
SILE.typesetter:leaveHmode()
SILE.settings:set("document.lskip", leftindent)
SILE.settings:set("document.rskip", leftindent)

SILE.call("noindent")
colorWrapper("note", function ()
SILE.call("hrule", { width = linethickness, height = linethickness, depth = linedimen })
Expand All @@ -446,6 +446,8 @@ function package:registerCommands ()
SILE.settings:set("document.rskip", SILE.types.node.glue(leftindent + innerindent))
SILE.call("font", { size = "0.95em", style = "italic " }, content)
SILE.call("novbreak")
SILE.typesetter:pushVglue(SILE.types.node.vglue(-0.5 * linedimen))
SILE.call("novbreak")
end)

SILE.call("noindent")
Expand All @@ -454,10 +456,9 @@ function package:registerCommands ()
SILE.call("hfill")
SILE.call("hrule", { width = 3 * linedimen, depth = linethickness })
SILE.call("hrule", { width = linethickness, depth = linethickness, height = linedimen })
SILE.typesetter:leaveHmode()
end)
SILE.typesetter:leaveHmode()
end)
SILE.call("smallskip")
end, "Outputs its content as a note in a specific boxed and indented block")
end

Expand Down
26 changes: 13 additions & 13 deletions tests/alignment.expected
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Mx 4.4700
Mx 5.4200
T 72 a=5.0000 86 a=5.3100 67 a=4.9300 70 a=4.4700 83 a=3.7200 72 a=5.0000 83 a=3.7200 70 a=4.4700 79 a=5.4200 (gubergren)
Mx 26.8819
My 95.9564
My 85.9564
Set font Libertinus Serif;10;400;Italic;normal;;;LTR
Mx 5.8700
Mx 4.5700
Expand Down Expand Up @@ -200,7 +200,7 @@ T 68 80 79 84 70 85 70 85 86 83 w=42.9300 (consetetur)
Mx 239.8919
T 84 66 69 74 81 84 68 74 79 72 w=42.7400 (sadipscing)
Mx 14.8819
My 107.9564
My 97.9564
T 70 77 74 85 83 w=16.7000 (elitr)
Mx 33.8353
Mx 3.9000
Expand Down Expand Up @@ -250,7 +250,7 @@ Mx 3.6400
Mx 4.4700
T 69 a=5.0600 80 a=5.0400 77 a=2.6400 80 a=5.0400 83 a=3.7200 70 a=4.4700 (dolore)
Mx 14.8819
My 119.9564
My 109.9564
T 78 66 72 79 66 w=27.4600 (magna)
Mx 44.8368
T 66 77 74 82 86 90 66 78 w=37.8800 (aliquyam)
Expand Down Expand Up @@ -293,7 +293,7 @@ T 66 68 68 86 84 66 78 w=34.8100 (accusam)
Mx 275.1259
T 70 85 w=7.6300 (et)
Mx 14.8819
My 131.9564
My 121.9564
T 75 86 84 85 80 w=20.1300 (justo)
Mx 37.5119
T 69 86 80 w=15.4100 (duo)
Expand Down Expand Up @@ -335,7 +335,7 @@ Mx 4.4700
Mx 5.4200
T 72 a=5.0000 86 a=5.3100 67 a=4.9300 70 a=4.4700 83 a=3.7200 72 a=5.0000 83 a=3.7200 70 a=4.4700 79 a=5.4200 (gubergren)
Mx 18.9889
My 163.9564
My 143.9564
Set font Libertinus Serif;10;400;Italic;normal;;;LTR
Mx 6.4600
Mx 4.4700
Expand Down Expand Up @@ -369,7 +369,7 @@ T 84 66 69 74 81 84 68 74 79 72 w=42.7400 (sadipscing)
Mx 261.9489
T 70 77 74 85 83 w=16.7000 (elitr)
Mx 23.2489
My 175.9564
My 155.9564
Mx 3.9000
Mx 4.5400
Mx 5.0600
Expand Down Expand Up @@ -417,7 +417,7 @@ Mx 3.6400
Mx 4.4700
T 69 a=5.0600 80 a=5.0400 77 a=2.6400 80 a=5.0400 83 a=3.7200 70 a=4.4700 (dolore)
Mx 14.8819
My 187.9564
My 167.9564
T 78 66 72 79 66 w=27.4600 (magna)
Mx 44.8368
T 66 77 74 82 86 90 66 78 w=37.8800 (aliquyam)
Expand Down Expand Up @@ -460,7 +460,7 @@ T 66 68 68 86 84 66 78 w=34.8100 (accusam)
Mx 275.1259
T 70 85 w=7.6300 (et)
Mx 37.0639
My 199.9564
My 179.9564
T 75 86 84 85 80 w=20.1300 (justo)
Mx 59.6939
T 69 86 80 w=15.4100 (duo)
Expand Down Expand Up @@ -502,7 +502,7 @@ Mx 4.4700
Mx 5.4200
T 72 a=5.0000 86 a=5.3100 67 a=4.9300 70 a=4.4700 83 a=3.7200 72 a=5.0000 83 a=3.7200 70 a=4.4700 79 a=5.4200 (gubergren)
Mx 26.8819
My 231.9564
My 201.9564
Set font Libertinus Serif;10;400;Italic;normal;;;LTR
Mx 3.2200
Mx 5.3100
Expand Down Expand Up @@ -536,7 +536,7 @@ T 84 66 69 74 81 84 68 74 79 72 w=42.7400 (sadipscing)
Mx 266.0559
T 70 77 74 85 83 w=16.7000 (elitr)
Mx 14.8819
My 243.9564
My 213.9564
Mx 3.9000
Mx 4.5400
Mx 5.0600
Expand Down Expand Up @@ -588,7 +588,7 @@ T 78 66 w=12.4700 (ma)
Mx 279.3759
T 14 w=3.3800 (-)
Mx 14.8819
My 255.9564
My 225.9564
T 72 79 66 w=14.9900 (gna)
Mx 33.5004
T 66 77 74 82 86 90 66 78 w=37.8800 (aliquyam)
Expand Down Expand Up @@ -631,7 +631,7 @@ T 66 68 68 86 84 66 78 w=34.8100 (accusam)
Mx 275.1259
T 70 85 w=7.6300 (et)
Mx 14.8819
My 267.9564
My 237.9564
T 75 86 84 85 80 w=20.1300 (justo)
Mx 37.5174
T 69 86 80 w=15.4100 (duo)
Expand Down Expand Up @@ -673,7 +673,7 @@ Mx 4.4700
Mx 5.4200
T 72 a=5.0000 86 a=5.3100 67 a=4.9300 70 a=4.4700 83 a=3.7200 72 a=5.0000 83 a=3.7200 70 a=4.4700 79 a=5.4200 (gubergren)
Mx 138.2259
My 299.9564
My 259.9564
Set font Libertinus Serif;10;400;Italic;normal;;;LTR
T 51 74 72 73 85 w=22.1200 (Right)
Mx 162.8459
Expand Down
1 change: 1 addition & 0 deletions tests/bug-1647.sil
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions tests/bug-262.expected
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,13 @@ T 72 87 w=8.0615 (et)
Mx 252.9827
My 43.4739
T 55 75 76 86 w=17.5977 (This)
Mx 273.2242
Mx 273.2254
T 76 86 w=6.5723 (is)
Mx 282.4402
Mx 282.4427
T 68 81 w=10.1074 (an)
Mx 295.1915
Mx 295.1952
T 76 81 71 72 81 87 72 71 w=36.8262 (indented)
Mx 334.6615
T 72 81 w=10.1367 (en)
Mx 344.7982
T 89 76 w=7.6416 (vi)
Mx 352.4398
T 85 82 81 w=14.5068 (ron)
Mx 366.9466
T 80 72 81 87 w=21.6113 (ment)
Mx 334.6664
T 72 81 89 76 85 82 81 80 72 81 87 w=53.8965 (environment)
End page
Finish
Loading

0 comments on commit 3cf4adf

Please sign in to comment.