diff --git a/classes/book.lua b/classes/book.lua index 882580f1e..20a0290d2 100644 --- a/classes/book.lua +++ b/classes/book.lua @@ -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 (_, _) @@ -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) @@ -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") @@ -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") diff --git a/classes/plain.lua b/classes/plain.lua index d69860f0a..876f2abe0 100644 --- a/classes/plain.lua +++ b/classes/plain.lua @@ -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: diff --git a/core/settings.lua b/core/settings.lua index ad8ba4d0a..4db053fdc 100644 --- a/core/settings.lua +++ b/core/settings.lua @@ -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.."'") @@ -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.."'") diff --git a/tests/bug-1699.expected b/tests/bug-1699.expected new file mode 100644 index 000000000..f3c6ab1de --- /dev/null +++ b/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 diff --git a/tests/bug-1699.sil b/tests/bug-1699.sil new file mode 100644 index 000000000..32f3f4474 --- /dev/null +++ b/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} diff --git a/tests/bug-192.expected b/tests/bug-192.expected index 6c3b76a43..3d2eaff63 100644 --- a/tests/bug-192.expected +++ b/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 (اب) diff --git a/tests/bug-262.expected b/tests/bug-262.expected index 265ad6c11..b399b878a 100644 --- a/tests/bug-262.expected +++ b/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) diff --git a/tests/bug-39.expected b/tests/bug-39.expected index 7810aebe3..0ffb28426 100644 --- a/tests/bug-39.expected +++ b/tests/bug-39.expected @@ -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 diff --git a/tests/chapterverse.expected b/tests/chapterverse.expected index f18981838..6ecdaab62 100644 --- a/tests/chapterverse.expected +++ b/tests/chapterverse.expected @@ -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 diff --git a/tests/disappearing-skip.expected b/tests/disappearing-skip.expected index 99af405cf..c048fea84 100644 --- a/tests/disappearing-skip.expected +++ b/tests/disappearing-skip.expected @@ -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 diff --git a/typesetters/base.lua b/typesetters/base.lua index 2fa06ba85..6c6584884 100644 --- a/typesetters/base.lua +++ b/typesetters/base.lua @@ -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)