Skip to content

Commit

Permalink
Merge 45bb576 into 00151bc
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia committed Apr 11, 2023
2 parents 00151bc + 45bb576 commit bf584dc
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 30 deletions.
10 changes: 10 additions & 0 deletions classes/book.lua
Expand Up @@ -118,6 +118,7 @@ function class:registerCommands ()

self:registerCommand("book:chapter:post", function (_, _)
SILE.call("par")
SILE.call("noindent")
end)

self:registerCommand("book:section:post", function (_, _)
Expand Down Expand Up @@ -164,6 +165,9 @@ function class:registerCommands ()
end)
SILE.call("bigskip")
SILE.call("nofoliothispage")
-- English typography (notably) expects the first paragraph under a section
-- not to be indented. Frenchies, don't use this class :)
SILE.call("noindent")
end, "Begin a new chapter")

self:registerCommand("section", function (options, content)
Expand Down Expand Up @@ -203,6 +207,9 @@ function class:registerCommands ()
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")

Expand All @@ -229,6 +236,9 @@ function class:registerCommands ()
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")

Expand Down
11 changes: 1 addition & 10 deletions classes/plain.lua
Expand Up @@ -335,16 +335,7 @@ function class:registerCommands ()

self:registerCommand("hbox", function (_, content)
local hbox, hlist = SILE.typesetter:makeHbox(content)
-- HACK
-- Direct insertion in the typesetter node queue comes from
-- the original implementation.
-- It would likely be clearer to use: SILE.typesetter:pushHbox(hbox)
-- but the latter adds a zerohbox sometimes (on initline), so it will
-- break some non-regression test and possibly have some effect at
-- places... For now, therefore, keep that unchanged, but it should
-- be investigated.
table.insert(SILE.typesetter.state.nodes, hbox)

SILE.typesetter:pushHbox(hbox)
if #hlist > 0 then
SU.warn("Hbox has migrating content (ignored for now, but likely to break in future versions)")
-- Ugly shim:
Expand Down
29 changes: 29 additions & 0 deletions core/settings.lua
Expand Up @@ -143,6 +143,11 @@ function settings:toplevelState ()
end

function settings:get (parameter)
-- HACK FIXME https://github.com/sile-typesetter/sile/issues/1699
-- See comment on set() below.
if parameter == "current.parindent" then
return SILE.typesetter and SILE.typesetter.state.parindent
end
if not parameter then self, parameter = deprecator(), self end
if not self.declarations[parameter] then
SU.error("Undefined setting '"..parameter.."'")
Expand All @@ -155,6 +160,30 @@ function settings:get (parameter)
end

function settings:set (parameter, value, makedefault, reset)
-- HACK FIXME https://github.com/sile-typesetter/sile/issues/1699
-- Anything dubbed current.xxx should likely NOT be a "setting" (subject
-- to being pushed/popped via temporary stacking) and actually has its
-- own lifecycle (e.g. reset for the next paragraph).
-- These should be rather typesetter states, or something to that extent
-- yet to clarify. Notably, current.parindent falls in that category,
-- BUT probably current.hangAfter and current.hangIndent too.
-- To avoid breaking too much code yet without being sure of the solution,
-- we implement a hack of sorts for current.parindent only.
-- Note moreover that current.parindent is currently probably a bad concept
-- anyway:
-- - It can be nil (= document.parindent applies)
-- - It can be a zero-glue (\noindent, ragged environments, etc.)
-- - It can be a valued glue set to document.parindent
-- (e.g. from \indent, and document.parindent thus applies)
-- - It could be another valued glue (uh, use case to ascertain)
-- What we would _likely_ only need to track is whether document.parindent
-- applies or not on the paragraph just composed afterwards...
if parameter == "current.parindent" then
if SILE.typesetter and not SILE.typesetter.state.hmodeOnly then
SILE.typesetter.state.parindent = SU.cast("glue or nil", value)
end
return
end
if type(self) ~= "table" then self, parameter, value, makedefault, reset = deprecator(), self, parameter, value, makedefault end
if not self.declarations[parameter] then
SU.error("Undefined setting '"..parameter.."'")
Expand Down
18 changes: 18 additions & 0 deletions tests/bug-1699.expected
@@ -0,0 +1,18 @@
Set paper size 209.7637818 297.6377985
Begin page
Mx 10.4882
My 22.3038
Set font Gentium Plus;10;400;Italic;normal;;;LTR
T 73 82 82 w=11.1670 (foo)
Mx 30.4882
My 34.3038
Set font Gentium Plus;10;400;;normal;;;LTR
T 69 68 85 w=13.6279 (bar)
Mx 10.4882
My 46.3038
T 73 82 82 w=13.1689 (foo)
Mx 30.4882
My 58.3038
T 69 68 85 w=13.6279 (bar)
End page
Finish
13 changes: 13 additions & 0 deletions tests/bug-1699.sil
@@ -0,0 +1,13 @@
\begin[class=plain,papersize=a7]{document}
\nofolios
% Both "bar" entries should have parindent applied
\noindent
\em{foo}

bar

\noindent
foo

bar
\end{document}
3 changes: 1 addition & 2 deletions tests/bug-192.expected
@@ -1,8 +1,7 @@
Set paper size 297.6377985 419.5275636
Begin page
Mx 14.8819
My 20.9764
Mx 34.8819
My 20.9764
My 381.3449
Set font Noto Naskh Arabic;18;400;;normal;;;RTL
T 35 3 w=18.1800 (اب)
Expand Down
3 changes: 1 addition & 2 deletions tests/bug-262.expected
@@ -1,8 +1,7 @@
Set paper size 419.5275636 595.275597
Begin page
Mx 8.3906
My 11.9055
Mx 28.3906
My 11.9055
My 454.9055
Set font Gentium Plus;10;400;;normal;;;LTR
T 79 82 85 72 80 w=24.3506 (lorem)
Expand Down
8 changes: 4 additions & 4 deletions tests/bug-39.expected
Expand Up @@ -8,14 +8,14 @@ Mx 76.2453
T 83 68 74 72 w=19.3848 (page)
Mx 98.2998
T 87 72 91 87 w=16.5332 (text)
Mx 54.8208
Mx 34.8208
My 28.9983
T 41 76 85 86 87 w=18.7549 (First)
Mx 76.2429
Mx 56.2451
T 47 76 81 72 w=17.6074 (Line)
Mx 96.5176
Mx 76.5220
T 82 73 w=8.1396 (of)
Mx 107.3244
Mx 87.3311
T 43 72 68 71 72 85 w=29.5264 (Header)
Mx 54.8208
My 63.6754
Expand Down
8 changes: 4 additions & 4 deletions tests/chapterverse.expected
Expand Up @@ -19,14 +19,14 @@ New page
Mx 32.0256
My 42.0943
T 69 68 93 w=13.9111 (baz)
Mx 49.3669
Mx 29.3669
My 17.0138
T 42 81 w=11.3477 (Gn)
Mx 63.3572
Mx 43.3572
T 20 w=4.6924 (1)
Mx 68.0495
Mx 48.0495
T 15 w=2.2900 (,)
Mx 72.9822
Mx 52.9822
T 22 w=4.6924 (3)
End page
Finish
14 changes: 7 additions & 7 deletions tests/disappearing-skip.expected
Expand Up @@ -29,21 +29,21 @@ Mx 69.1579
T 58 82 81 71 72 85 79 68 81 71 w=76.2671 (Wonderland)
Mx 145.4250
T 171 w=10.0342 (…)
Mx 18.2835
Mx 38.2835
My 63.4155
Set font Gentium Plus;10;400;;normal;;;LTR
T 58 75 72 85 72 w=27.2168 (Where)
Mx 48.1667
Mx 68.1645
T 71 76 71 w=13.1104 (did)
Mx 63.9434
Mx 83.9390
T 80 92 w=12.9639 (my)
Mx 79.5737
Mx 99.5671
T 86 78 76 83 w=16.7480 (skip)
Mx 98.9881
Mx 118.9793
T 77 88 86 87 w=15.1904 (just)
Mx 116.8449
Mx 136.8339
T 74 82 w=9.9072 (go)
Mx 126.7522
Mx 146.7412
T 34 w=4.3311 (?)
Mx 180.4885
My 522.3893
Expand Down
2 changes: 1 addition & 1 deletion typesetters/base.lua
Expand Up @@ -283,7 +283,7 @@ function typesetter:typeset (text)
end

function typesetter:initline ()
if self.state.hmodeOnly then return end
if self.state.hmodeOnly then return end -- https://github.com/sile-typesetter/sile/issues/1718
if (#self.state.nodes == 0) then
self.state.nodes[#self.state.nodes+1] = SILE.nodefactory.zerohbox()
SILE.documentState.documentClass.newPar(self)
Expand Down

0 comments on commit bf584dc

Please sign in to comment.