Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all setting parameter names lower case #1939

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions classes/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ function class.declareSettings (_)
help = "Glue at start of paragraph"
})
SILE.settings:declare({
parameter = "current.hangIndent",
parameter = "current.hangindent",
type = "measurement or nil",
default = nil,
help = "Size of hanging indent"
})
SILE.settings:declare({
parameter = "current.hangAfter",
parameter = "current.hangafter",
type = "integer or nil",
default = nil,
help = "Number of lines affected by handIndent"
Expand Down Expand Up @@ -539,26 +539,26 @@ function class.newPar (typesetter)
-- unlikely. And anyway pushback() has plenty of other issues.
typesetter:pushGlue(parindent:absolute())
SILE.settings:set("current.parindent", nil)
local hangIndent = SILE.settings:get("current.hangIndent")
local hangIndent = SILE.settings:get("current.hangindent")
if hangIndent then
SILE.settings:set("linebreak.hangIndent", hangIndent)
SILE.settings:set("linebreak.hangindent", hangIndent)
end
local hangAfter = SILE.settings:get("current.hangAfter")
local hangAfter = SILE.settings:get("current.hangafter")
if hangAfter then
SILE.settings:set("linebreak.hangAfter", hangAfter)
SILE.settings:set("linebreak.hangafter", hangAfter)
end
end

-- WARNING: not called as class method
function class.endPar (typesetter)
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)
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)
if SILE.settings:get("current.hangafter") then
SILE.settings:set("current.hangafter", nil)
SILE.settings:set("linebreak.hangafter", nil)
end
end

Expand Down
46 changes: 23 additions & 23 deletions core/break.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
SILE.settings:declare({ parameter = "linebreak.parShape", type = "boolean", default = false,
SILE.settings:declare({ parameter = "linebreak.parshape", type = "boolean", default = false,
help = "If set to true, the paragraph shaping method is activated." })
SILE.settings:declare({ parameter = "linebreak.tolerance", type = "integer or nil", default = 500 })
SILE.settings:declare({ parameter = "linebreak.pretolerance", type = "integer or nil", default = 100 })
SILE.settings:declare({ parameter = "linebreak.hangIndent", type = "measurement", default = 0 })
SILE.settings:declare({ parameter = "linebreak.hangAfter", type = "integer or nil", default = nil })
SILE.settings:declare({ parameter = "linebreak.hangindent", type = "measurement", default = 0 })
SILE.settings:declare({ parameter = "linebreak.hangafter", type = "integer or nil", default = nil })
SILE.settings:declare({ parameter = "linebreak.adjdemerits", type = "integer", default = 10000,
help = "Additional demerits which are accumulated in the course of paragraph building when two consecutive lines are visually incompatible. In these cases, one line is built with much space for justification, and the other one with little space." })
SILE.settings:declare({ parameter = "linebreak.looseness", type = "integer", default = 0 })
SILE.settings:declare({ parameter = "linebreak.prevGraf", type = "integer", default = 0 })
SILE.settings:declare({ parameter = "linebreak.emergencyStretch", type = "measurement", default = 0 })
SILE.settings:declare({ parameter = "linebreak.doLastLineFit", type = "boolean", default = false }) -- unimplemented
SILE.settings:declare({ parameter = "linebreak.linePenalty", type = "integer", default = 10 })
SILE.settings:declare({ parameter = "linebreak.hyphenPenalty", type = "integer", default = 50 })
SILE.settings:declare({ parameter = "linebreak.doubleHyphenDemerits", type = "integer", default = 10000 })
SILE.settings:declare({ parameter = "linebreak.finalHyphenDemerits", type = "integer", default = 5000 })
SILE.settings:declare({ parameter = "linebreak.prevgraf", type = "integer", default = 0 })
SILE.settings:declare({ parameter = "linebreak.emergencystretch", type = "measurement", default = 0 })
SILE.settings:declare({ parameter = "linebreak.dolastlinefit", type = "boolean", default = false }) -- unimplemented
SILE.settings:declare({ parameter = "linebreak.linepenalty", type = "integer", default = 10 })
SILE.settings:declare({ parameter = "linebreak.hyphenpenalty", type = "integer", default = 50 })
SILE.settings:declare({ parameter = "linebreak.doublehyphendemerits", type = "integer", default = 10000 })
SILE.settings:declare({ parameter = "linebreak.finalhyphendemerits", type = "integer", default = 5000 })

-- doubleHyphenDemerits
-- hyphenPenalty
-- doublehyphendemerits
-- hyphenpenalty

local classes = { "tight"; "decent"; "loose"; "veryLoose" }
local passSerial = 0
Expand Down Expand Up @@ -75,7 +75,7 @@ function lineBreak:trimGlue() -- 842
nodes[#nodes+1] = SILE.nodefactory.penalty(inf_bad)
end

-- NOTE FOR DEVELOPERS: this method is called when the linebreak.parShape
-- NOTE FOR DEVELOPERS: this method is called when the linebreak.parshape
-- setting is true. The arguments passed are self (the linebreaker instance)
-- and a counter representing the current line number.
--
Expand Down Expand Up @@ -125,13 +125,13 @@ function lineBreak.parShapeCacheClear(_)
end

function lineBreak:setupLineLengths() -- 874
self.parShaping = param("parShape") or false
self.parShaping = param("parshape") or false
if self.parShaping then
self.lastSpecialLine = nil
self.easy_line = nil
else
self.hangAfter = param("hangAfter") or 0
self.hangIndent = param("hangIndent"):tonumber()
self.hangAfter = param("hangafter") or 0
self.hangIndent = param("hangindent"):tonumber()
if self.hangIndent == 0 then
self.lastSpecialLine = 0
self.secondWidth = self.hsize or SU.error("No hsize")
Expand All @@ -154,7 +154,7 @@ function lineBreak:tryBreak() -- 855
local pi, breakType
local node = self.nodes[self.place]
if not node then pi = ejectPenalty; breakType = "hyphenated"
elseif node.is_discretionary then breakType = "hyphenated"; pi = param("hyphenPenalty")
elseif node.is_discretionary then breakType = "hyphenated"; pi = param("hyphenpenalty")
else breakType = "unhyphenated"; pi = node.penalty or 0 end
if debugging then SU.debug("break", "Trying a ", breakType, "break p =", pi) end
self.no_break_yet = true -- We have to store all this state crap in the object, or it's global variables all the way
Expand Down Expand Up @@ -354,7 +354,7 @@ end

function lineBreak:computeDemerits(pi, breakType)
if self.artificialDemerits then return 0 end
local demerit = param("linePenalty") + self.badness
local demerit = param("linepenalty") + self.badness
if math.abs(demerit) >= 10000 then
demerit = 100000000
else
Expand All @@ -369,9 +369,9 @@ function lineBreak:computeDemerits(pi, breakType)
end
if breakType == "hyphenated" and self.r.type == "hyphenated" then
if self.nodes[self.place] then
demerit = demerit + param("doubleHyphenDemerits")
demerit = demerit + param("doublehyphendemerits")
else
demerit = demerit + param("finalHyphenDemerits")
demerit = demerit + param("finalhyphendemerits")
end
end
-- XXX adjDemerits not added here
Expand Down Expand Up @@ -578,7 +578,7 @@ function lineBreak:doBreak (nodes, hsize, sideways)
else
self.threshold = param("tolerance")
self.pass = "second"
self.finalpass = param("emergencyStretch") <= 0
self.finalpass = param("emergencystretch") <= 0
end
-- 889
while 1 do
Expand All @@ -600,7 +600,7 @@ function lineBreak:doBreak (nodes, hsize, sideways)
type = "unhyphenated",
fitness = "decent",
next = self.activeListHead,
lineNumber = param("prevGraf") + 1,
lineNumber = param("prevgraf") + 1,
totalDemerits = 0
}

Expand All @@ -621,7 +621,7 @@ function lineBreak:doBreak (nodes, hsize, sideways)
self.threshold = param("tolerance")
else
self.pass = "emergency"
self.background.stretch:___add(param("emergencyStretch"))
self.background.stretch:___add(param("emergencystretch"))
self.finalpass = true
end
end
Expand Down
11 changes: 10 additions & 1 deletion core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ function settings:_init()

SILE.registerCommand("set", function(options, content)
local parameter = SU.required(options, "parameter", "\\set command")
local lower = parameter:lower()
if parameter ~= lower then
SU.deprecated(('SILE.settings:set("%s")'):format(parameter), (':set("%s")'):format(lower), "0.14.0", "0.17.0",
[[
All setting parameter names should be lower case.
Previously we had a mix of lowercase and camelCase.
In the future only lowercase will be accepted.]])
parameter = lower
end
local makedefault = SU.boolean(options.makedefault, false)
local reset = SU.boolean(options.reset, false)
local value = options.value
Expand Down Expand Up @@ -165,7 +174,7 @@ function settings:set (parameter, value, makedefault, reset)
-- 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.
-- 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
Expand Down
7 changes: 4 additions & 3 deletions core/utilities/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ utilities.deprecated = function (old, new, warnat, errorat, extra)
-- will never encounter this failure, but as a developer it’s hard to test a
-- deprecation when core code refactoring is an all-or-nothing proposition.
-- Hence we fake it ‘till we make it, all deprecations internally are warnings.
local brackets = old:sub(1,1) == '\\' and "" or "()"
local _new = new and "Please use " .. (new .. brackets) .. " instead." or "Plase don't use it."
local msg = (old .. brackets) .. " was deprecated in SILE v" .. tostring(warnat) .. ". " .. _new .. (extra and "\n" .. extra .. "\n\n" or "")
local parens = old:sub(-1,-1) == ')' and "" or "()"
local prettysuffix = old:sub(1,1) == '\\' and "" or parens
local _new = new and "Please use " .. (new .. prettysuffix) .. " instead." or "Plase don't use it."
local msg = (old .. prettysuffix) .. " was deprecated in SILE v" .. tostring(warnat) .. ". " .. _new .. (extra and "\n" .. extra .. "\n\n" or "")
if errorat and current >= errorat then
SU.error(msg)
elseif warnat and current >= warnat then
Expand Down
24 changes: 12 additions & 12 deletions documentation/c07-settings.sil
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ Assuming italics is slanted forward (in left-to-right writing direction) and tha
Be aware, nevertheless, that this solution cannot be made perfect, even assuming a reasonable choice of fonts.
Pathological cases may still occur, even in latin scripts, for which there is no solution but using manual kerning.

To enable automated italic correction, you can set the \autodoc:setting{typesetter.italicCorrection} setting to \code{true}.
To enable automated italic correction, you can set the \autodoc:setting{typesetter.italiccorrection} setting to \code{true}.
Let’s turn it on and check how our previous gibberish now behaves.

\begin{autodoc:example}%
\set[parameter=typesetter.italicCorrection, value=true]{%
\set[parameter=typesetter.italiccorrection, value=true]{%
\quad{}(\em{fluff}) ¡\em{fancyful proof}! [\em{puff}] \em{fluff}ⁿ
\par}
\end{autodoc:example}
Expand All @@ -310,16 +310,16 @@ are doing with these.
\item{\autodoc:setting{linebreak.tolerance}: How bad a breakpoint is before it is
rejected by the algorithm.
(Default: 500)}
\item{\autodoc:setting{linebreak.parShape}: Whether to utilize a callback to
\code{SILE.linebreak:parShape()} to get a customized shape for each line in a paragraph.
\item{\autodoc:setting{linebreak.parshape}: Whether to utilize a callback to
\code{SILE.linebreak:parshape()} to get a customized shape for each line in a paragraph.
(Default: false)}
\item{\autodoc:setting{linebreak.pretolerance}: If there are no breakpoints better than
this, the paragraph is considered for hyphenation.
(Default: 100)}
\item{\autodoc:setting{linebreak.hangIndent}: How far to indent initial line(s) of a paragraph.
\item{\autodoc:setting{linebreak.hangindent}: How far to indent initial line(s) of a paragraph.
(Default: 0)}
\item{\autodoc:setting{linebreak.hangAfter}: An integer count of how many lines should have
\autodoc:setting{linebreak.hangIndent} applied.
\item{\autodoc:setting{linebreak.hangafter}: An integer count of how many lines should have
\autodoc:setting{linebreak.hangindent} applied.
(Default: nil)}
\item{\autodoc:setting{linebreak.adjdemerits}: Additional demerits which are accumulated in the
course of paragraph building when two consecutive lines are visually incompatible. In these
Expand All @@ -328,16 +328,16 @@ are doing with these.
\item{\autodoc:setting{linebreak.looseness}: How many lines the current paragraph should
be made longer than normal.
(Default: 0)}
\item{\autodoc:setting{linebreak.prevGraf}: The number of lines in the paragraph last added to
\item{\autodoc:setting{linebreak.prevgraf}: The number of lines in the paragraph last added to
the vertical list.}
\item{\autodoc:setting{linebreak.emergencyStretch}: Assumed extra stretchability in lines of a
\item{\autodoc:setting{linebreak.emergencystretch}: Assumed extra stretchability in lines of a
paragraph.
(Default: 0)}
\item{\autodoc:setting{linebreak.linePenalty}: Penalty value associated with each line break.
\item{\autodoc:setting{linebreak.linepenalty}: Penalty value associated with each line break.
(Default: 10)}
\item{\autodoc:setting{linebreak.hyphenPenalty}: Penalty associated with break at a hyphen.
\item{\autodoc:setting{linebreak.hyphenpenalty}: Penalty associated with break at a hyphen.
(Default: 50)}
\item{\autodoc:setting{linebreak.doubleHyphenDemerits}: Penalty for consecutive lines ending
\item{\autodoc:setting{linebreak.doublehyphendemerits}: Penalty for consecutive lines ending
with a hyphen.
(Default: 10000)}
\end{itemize}
Expand Down
2 changes: 1 addition & 1 deletion documentation/sile.sil
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% Quite drastic value below, but for a fast-changing technical document with snippets of code,
% and little resources for fine-checking and tuning, we prefer (possibly large) underfull lines
% to ugly overfull ones:
\set[parameter=linebreak.emergencyStretch,value=20%lw]
\set[parameter=linebreak.emergencystretch,value=20%lw]
\set[parameter=autodoc.highlighting, value=true]
\font[size=11pt,family=Gentium Book Basic]
\nofolios
Expand Down
6 changes: 3 additions & 3 deletions packages/dropcaps/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ function package:registerCommands ()

-- Setup up the necessary indents for the final paragraph content
local joinOffset = join and standoff:tonumber() or 0
SILE.settings:set("current.hangAfter", -lines)
SILE.settings:set("current.hangIndent", targetWidth + joinOffset)
SU.debug("dropcaps", "joinOffset", joinOffset)
SILE.settings:set("current.hangafter", -lines)
SILE.settings:set("current.hangindent", targetWidth + joinOffset)
SU.debug("dropcaps", "joinoffset", joinOffset)

-- The paragraph is indented so as to leave enough space for the drop cap.
-- We "trick" the typesetter with a zero-dimension box wrapping our original box.
Expand Down
8 changes: 4 additions & 4 deletions packages/folio/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function package:outputFolio (frame)
-- Reset settings the document may have but should not be applied to footnotes
-- See also same resets in footnote package
for _, v in ipairs({
"current.hangAfter",
"current.hangIndent",
"linebreak.hangAfter",
"linebreak.hangIndent" }) do
"current.hangafter",
"current.hangindent",
"linebreak.hangafter",
"linebreak.hangindent" }) do
SILE.settings:set(v, SILE.settings.defaults[v])
end

Expand Down
8 changes: 4 additions & 4 deletions packages/footnotes/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ function package:registerCommands ()
-- Reset settings the document may have but should not be applied to footnotes
-- See also same resets in folio package
for _, v in ipairs({
"current.hangAfter",
"current.hangIndent",
"linebreak.hangAfter",
"linebreak.hangIndent" }) do
"current.hangafter",
"current.hangindent",
"linebreak.hangafter",
"linebreak.hangindent" }) do
SILE.settings:set(v, SILE.settings.defaults[v])
end

Expand Down
12 changes: 6 additions & 6 deletions packages/url/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ end
function package.declareSettings (_)

SILE.settings:declare({
parameter = "url.linebreak.primaryPenalty",
parameter = "url.linebreak.primarypenalty",
type = "integer",
default = 100,
help = "Penalty for breaking lines in URLs at preferred breakpoints"
})

SILE.settings:declare({
parameter = "url.linebreak.secondaryPenalty",
parameter = "url.linebreak.secondarypenalty",
type = "integer",
default = 200,
help = "Penalty for breaking lines in URLs at tolerable breakpoints (should be higher than url.linebreak.primaryPenalty)"
help = "Penalty for breaking lines in URLs at tolerable breakpoints (should be higher than url.linebreak.primarypenalty)"
})

end
Expand Down Expand Up @@ -121,8 +121,8 @@ function package:registerCommands ()

self:registerCommand("url", function (options, content)
SILE.settings:temporarily(function ()
local primaryPenalty = SILE.settings:get("url.linebreak.primaryPenalty")
local secondaryPenalty = SILE.settings:get("url.linebreak.secondaryPenalty")
local primaryPenalty = SILE.settings:get("url.linebreak.primarypenalty")
local secondaryPenalty = SILE.settings:get("url.linebreak.secondarypenalty")
local worsePenalty = primaryPenalty + secondaryPenalty

if options.language then
Expand Down Expand Up @@ -176,7 +176,7 @@ Note that if French (\code{fr}) is selected, the special typographic rules apply
To typeset a URL and also make it an active hyperlink, use the \autodoc:command{\href} command without the \autodoc:parameter{src} option,
but with the URL passed as argument.

The breaks are controlled by two penalty settings: \autodoc:setting{url.linebreak.primaryPenalty} for preferred breakpoints and, for less acceptable but still tolerable breakpoints, \autodoc:setting{url.linebreak.secondaryPenalty}—its value should logically be higher than the previous one.
The breaks are controlled by two penalty settings: \autodoc:setting{url.linebreak.primarypenalty} for preferred breakpoints and, for less acceptable but still tolerable breakpoints, \autodoc:setting{url.linebreak.secondarypenalty}—its value should logically be higher than the previous one.

The \autodoc:command{\urlstyle} command hook may be overridden to change the style of URLs.
By default, they are typeset as “code”.
Expand Down
2 changes: 1 addition & 1 deletion tests/bug-355-tr-hyphenation.sil
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
\nofolios
\neverindent
\set[parameter=shaper.variablespaces, value=false]
\set[parameter=linebreak.emergencyStretch,value=0]
\set[parameter=linebreak.emergencystretch,value=0]
\language[main=tr]

% Without stretchable spaces there is no variablility for SILE to do justification.
Expand Down
2 changes: 1 addition & 1 deletion tests/bug-79.sil
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
\frame[id=frame, left=2cm, width=5.8cm, top=2cm, bottom=10cm]
\end{pagetemplate}
\font[size=10pt,family=Libertinus Serif,language=cs]
\set[parameter=linebreak.emergencyStretch, value=0.5cm]
\set[parameter=linebreak.emergencystretch, value=0.5cm]
zana Bourová, zápolila ve čtyřech závodech, nejlépe se umístila na Benecku na 4. místě. Magdaléna Chrástová skončila na místě sedmnáctém, Barbora Šulcová byla hned za
\end{document}
Loading
Loading