Skip to content

Commit

Permalink
Merge branch 'sile-typesetter:master' into center-vertically
Browse files Browse the repository at this point in the history
  • Loading branch information
jodros committed Oct 27, 2023
2 parents 0e7ea06 + 72363c5 commit 2819867
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 14 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,23 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.14.12](https://github.com/sile-typesetter/sile/compare/v0.14.11...v0.14.12) (2023-10-11)


### Features

* **i18n:** Add Portuguese localizations for bibtex package ([#1859](https://github.com/sile-typesetter/sile/issues/1859)) ([f716c35](https://github.com/sile-typesetter/sile/commit/f716c35109d36c7cb2118ab9c7c65227d9941e01))
* **utilities:** Add utility function for console messages without trace info ([18526ce](https://github.com/sile-typesetter/sile/commit/18526ce75eeb8deb12e9b232e727993409ed8e06))


### Bug Fixes

* **build:** Make sure vendored luarocks isn't a phony target that runs repeatedly ([713434d](https://github.com/sile-typesetter/sile/commit/713434dadbc271299c8548dd2f2d4af57c1eec62))
* **core:** Allocate exactly what we use, not a guess with an extra just in case ([640ded0](https://github.com/sile-typesetter/sile/commit/640ded0a90e427124f555a2a48d263cde5300d7d))
* **core:** Correct usage of HarfBuzz when passing a filtered list of shapers ([f488643](https://github.com/sile-typesetter/sile/commit/f4886437d0ebf229db1c2779a8a324bf441efc1a))
* **core:** Fixup class loader so cache is all Lua module specs ([#1863](https://github.com/sile-typesetter/sile/issues/1863)) ([7efff5b](https://github.com/sile-typesetter/sile/commit/7efff5b7e94f0c4897910c064ef842e6be2e4ab1))
* **packages:** Don't warn on TOC content change if not actually used ([87c443d](https://github.com/sile-typesetter/sile/commit/87c443d1571f571b595c3e32febdcb03129f5b9a))

### [0.14.11](https://github.com/sile-typesetter/sile/compare/v0.14.10...v0.14.11) (2023-08-23)


Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -7,7 +7,7 @@ inputs:
default: ""
runs:
using: docker
image: docker://ghcr.io/sile-typesetter/sile:v0.14.11
image: docker://ghcr.io/sile-typesetter/sile:v0.14.12
entrypoint: sh
args:
- -c
Expand Down
15 changes: 13 additions & 2 deletions classes/base.lua
Expand Up @@ -79,7 +79,12 @@ end

function class:setOptions (options)
options = options or {}
options.papersize = options.papersize or "a4"
-- Classes that add options with dependencies should explicitly handle them, then exempt them from furthur processing.
-- The landscape option is handled explicitly before papersize, then the "rest" of options that are not interdependent.
self.options.landscape = SU.boolean(options.landscape, false)
options.landscape = nil
self.options.papersize = options.papersize or "a4"
options.papersize = nil
for option, value in pairs(options) do
self.options[option] = value
end
Expand All @@ -101,10 +106,16 @@ function class:declareOptions ()
end
return self._name
end)
self:declareOption("landscape", function(_, landscape)
if landscape then
self.landscape = landscape
end
return self.landscape
end)
self:declareOption("papersize", function (_, size)
if size then
self.papersize = size
SILE.documentState.paperSize = SILE.papersize(size)
SILE.documentState.paperSize = SILE.papersize(size, self.options.landscape)
SILE.documentState.orgPaperSize = SILE.documentState.paperSize
SILE.newFrame({
id = "page",
Expand Down
9 changes: 8 additions & 1 deletion configure.ac
Expand Up @@ -234,7 +234,14 @@ AC_SUBST([LUAROCKSARGS])

AX_SUBST_TRANSFORMED_PACKAGE_NAME

adl_RECURSIVE_EVAL(["${datadir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_PATH])
# Avoid need for `--datarootdir=$(cd ..; pwd)` hack to run locally for
# tests/manual build when developer mode is enabled
AM_COND_IF([DEVELOPER], [
adl_RECURSIVE_EVAL(["$(pwd)"], [SILE_PATH])
datarootdir="$(cd ..; pwd)"
],[
adl_RECURSIVE_EVAL(["${datadir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_PATH])
])
AC_DEFINE_UNQUOTED([SILE_PATH],["${SILE_PATH}"],[Path for SILE packages and classes])
AC_SUBST([SILE_PATH])

Expand Down
15 changes: 9 additions & 6 deletions core/papersize.lua
Expand Up @@ -63,16 +63,19 @@ local papersize = {
}

setmetatable(papersize, {
__call = function (self, size)
__call = function (self, size, landscape)
local geometry
local _, _, x, y = string.find(size, "(.+)%s+x%s+(.+)")
if x and y then
return { SILE.measurement(x):tonumber(), SILE.measurement(y):tonumber() }
geometry = { SILE.measurement(x):tonumber(), SILE.measurement(y):tonumber() }
else
size = string.lower(size:gsub("[-%s]+", ""))
if self[size] then
return self[size]
end
local preset_name = string.lower(size:gsub("[-%s]+", ""))
geometry = self[preset_name]
end
if SU.boolean(landscape) then
geometry[1], geometry[2] = geometry[2], geometry[1]
end
if geometry then return geometry end
SU.error(string.format([[Unable to parse papersize '%s'.
Custom sizes may be entered with 'papersize=<measurement> x <measurement>'.
Predefined paper sizes include: %s]],
Expand Down
8 changes: 8 additions & 0 deletions documentation/c03-input.sil
Expand Up @@ -61,6 +61,14 @@ Once some of the basic document properties have been set up using these fixed si
For example, once the paper size is set, percentage of page width (\code{\%pw}) and height(\code{\%ph}) become valid units.
In Chapter 4 we will meet more of these relative units, and in Chapter 7 we will meet some other ways of specifying lengths to make them stretchable or shrinkable.

\subsection{Setting orientation as landscape}

The orientation of the page is defined as "portrait" by default, but if you want to set it as landscape there is an option for that:

\begin[type=autodoc:codeblock]{raw}
\begin[landscape=true]{document}
\end{raw}

\section{Ordinary text}

On the whole, ordinary text isn’t particularly interesting—it’s just typeset.
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "sile",
"version": "0.14.11",
"version": "0.14.12",
"description": "The SILE Typesetter",
"main": "sile",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/cropmarks/init.lua
Expand Up @@ -70,7 +70,8 @@ function package:registerCommands ()

self:registerCommand("crop:setup", function (options, _)
local papersize = SU.required(options, "papersize", "setting up crop marks")
local size = SILE.papersize(papersize)
local landscape = SU.boolean(options.landscape, self.class.options.landscape)
local size = SILE.papersize(papersize, landscape)
local oldsize = SILE.documentState.paperSize
SILE.documentState.paperSize = size
local offsetx = ( SILE.documentState.paperSize[1] - oldsize[1] ) /2
Expand Down
6 changes: 5 additions & 1 deletion sile.in
Expand Up @@ -6,7 +6,11 @@ SHARED_LIB_EXT = "@SHARED_LIB_EXT@"

-- At this point at run time we may or may not have anything useful in package.path,
-- so require() isn't something we can rely on.
local status = pcall(dofile, "@SILE_PATH@/core/pathsetup.lua")
local status
for path in string.gmatch("@SILE_PATH@", "[^;]+") do
status = pcall(dofile, path .. "/core/pathsetup.lua")
if status then break end
end
if not status then
dofile("./core/pathsetup.lua")
end
Expand Down
7 changes: 6 additions & 1 deletion spec/measurements_spec.lua
Expand Up @@ -2,7 +2,7 @@ SILE = require("core.sile")
SU.warn = function () end

describe("The papersize parser", function()
local parse = SILE.paperSizeParser
local parse = SILE.papersize
it("should return the correct values for a6", function()
local a6 = { 297.6377985, 419.52756359999995 }
assert.is.same(parse("a6"), a6)
Expand All @@ -14,6 +14,11 @@ describe("The papersize parser", function()
assert.is.same(parse("2in x 4in"), size)
assert.is.same(parse("144 x 288"), size)
end)
it("should flip x and y page geometry for landscape mode", function()
local size = { 288, 144 }
assert.is.same(parse("2in x 4in", true), size)
assert.is.same(parse("144 x 288", true), size)
end)
it("error if unable to parse", function()
assert.has.errors(function () parse("notapaper") end)
assert.has.errors(function () parse(nil) end)
Expand Down
8 changes: 8 additions & 0 deletions tests/landscape.expected
@@ -0,0 +1,8 @@
Set paper size 841.8897729 595.275597
Begin page
Mx 418.5987
My 553.7327
Set font Gentium Plus;10;400;;normal;;;LTR
T 20 w=4.6924 (1)
End page
Finish
2 changes: 2 additions & 0 deletions tests/landscape.sil
@@ -0,0 +1,2 @@
\begin[landscape=true]{document}
\end{document}

0 comments on commit 2819867

Please sign in to comment.