diff --git a/.luacheckrc b/.luacheckrc index 8fb7f42a..d43b1b1d 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,39 +1,39 @@ std = "lua54" include_files = { - "**/*.lua", - "*.rockspec", - ".busted", - ".luacheckrc" + "**/*.lua", + "*.rockspec", + ".busted", + ".luacheckrc", } exclude_files = { - "casile-*", - "lua_modules", - "lua-libraries", - ".lua", - ".luarocks", - ".install" + "casile-*", + "lua_modules", + "lua-libraries", + ".lua", + ".luarocks", + ".install", } files["spec"] = { - std = "+busted" + std = "+busted", } files["pandoc-filters"] = { - globals = { - "Block", - "Header", - "Inline", - "Link", - "Note", - "Pandoc", - "pandoc" - }, - ignore = { "4.2" } + globals = { + "Block", + "Header", + "Inline", + "Link", + "Note", + "Pandoc", + "pandoc", + }, + ignore = { "4.2" }, } globals = { - "SILE", - "SU", - "luautf8", - "pl", - "fluent", - "CASILE" + "SILE", + "SU", + "luautf8", + "pl", + "fluent", + "CASILE", } max_line_length = false diff --git a/layouts/ekran.lua b/layouts/ekran.lua index d08b3c6f..a7151f28 100644 --- a/layouts/ekran.lua +++ b/layouts/ekran.lua @@ -3,41 +3,38 @@ return function (class) class.options.papersize = 1920 / 192 .. "in x " .. 1080 / 192 .. "in" if class._name == "cabook" then - class:loadPackage( - "masters", + class:loadPackage("masters", { { - { - id = "right", - firstContentFrame = "content", - frames = { - page = { - left = "0", - right = "100%pw", - top = "0", - bottom = "100%ph", - }, - content = { - left = "10%pw", - right = "100%pw-10%pw", - top = "bottom(runningHead)+1%ph", - bottom = "top(footnotes)-1%ph", - }, - runningHead = { - left = "left(content)", - right = "right(content)", - top = "2%ph", - bottom = "10%ph", - }, - footnotes = { - left = "left(content)", - right = "right(content)", - height = "0", - bottom = "100%ph-3%ph", - }, + id = "right", + firstContentFrame = "content", + frames = { + page = { + left = "0", + right = "100%pw", + top = "0", + bottom = "100%ph", + }, + content = { + left = "10%pw", + right = "100%pw-10%pw", + top = "bottom(runningHead)+1%ph", + bottom = "top(footnotes)-1%ph", + }, + runningHead = { + left = "left(content)", + right = "right(content)", + top = "2%ph", + bottom = "10%ph", + }, + footnotes = { + left = "left(content)", + right = "right(content)", + height = "0", + bottom = "100%ph-3%ph", }, }, - } - ) + }, + }) class:registerCommand("output-right-running-head", function (_, _) if not SILE.scratch.headers.right then diff --git a/layouts/halfletter.lua b/layouts/halfletter.lua index 3f620837..d68549b7 100644 --- a/layouts/halfletter.lua +++ b/layouts/halfletter.lua @@ -2,34 +2,31 @@ return function (class) class.options.papersize = "halfletter" if class._name == "cabook" then - class:loadPackage( - "masters", + class:loadPackage("masters", { { - { - id = "right", - firstContentFrame = "content", - frames = { - content = { - left = "left(page) + 22.5mm", - right = "right(page) - 15mm", - top = "top(page) + 20mm", - bottom = "top(footnotes)", - }, - runningHead = { - left = "left(content)", - right = "right(content)", - top = "top(content) - 8mm", - bottom = "top(content)", - }, - footnotes = { - left = "left(content)", - right = "right(content)", - height = "0", - bottom = "bottom(page) - 15mm", - }, + id = "right", + firstContentFrame = "content", + frames = { + content = { + left = "left(page) + 22.5mm", + right = "right(page) - 15mm", + top = "top(page) + 20mm", + bottom = "top(footnotes)", + }, + runningHead = { + left = "left(content)", + right = "right(content)", + top = "top(content) - 8mm", + bottom = "top(content)", + }, + footnotes = { + left = "left(content)", + right = "right(content)", + height = "0", + bottom = "bottom(page) - 15mm", }, }, - } - ) + }, + }) end end diff --git a/layouts/octavo.lua b/layouts/octavo.lua index d21c7065..1867b3ca 100644 --- a/layouts/octavo.lua +++ b/layouts/octavo.lua @@ -2,34 +2,31 @@ return function (class) class.options.papersize = "432pt x 648pt" if class._name == "cabook" then - class:loadPackage( - "masters", + class:loadPackage("masters", { { - { - id = "right", - firstContentFrame = "content", - frames = { - content = { - left = "left(page) + 22.5mm", - right = "right(page) - 15mm", - top = "top(page) + 20mm", - bottom = "top(footnotes)", - }, - runningHead = { - left = "left(content)", - right = "right(content)", - top = "top(content) - 8mm", - bottom = "top(content) - 2mm", - }, - footnotes = { - left = "left(content)", - right = "right(content)", - height = "0", - bottom = "bottom(page) - 15mm", - }, + id = "right", + firstContentFrame = "content", + frames = { + content = { + left = "left(page) + 22.5mm", + right = "right(page) - 15mm", + top = "top(page) + 20mm", + bottom = "top(footnotes)", + }, + runningHead = { + left = "left(content)", + right = "right(content)", + top = "top(content) - 8mm", + bottom = "top(content) - 2mm", + }, + footnotes = { + left = "left(content)", + right = "right(content)", + height = "0", + bottom = "bottom(page) - 15mm", }, }, - } - ) + }, + }) end end diff --git a/layouts/royaloctavo.lua b/layouts/royaloctavo.lua index 84754918..5a079cbb 100644 --- a/layouts/royaloctavo.lua +++ b/layouts/royaloctavo.lua @@ -2,40 +2,37 @@ return function (class) class.options.papersize = "165mm x 250mm" if class._name == "cabook" then - class:loadPackage( - "masters", + class:loadPackage("masters", { { - { - id = "right", - firstContentFrame = "content", - frames = { - content = { - left = "left(page) + 22.5mm", - right = "right(page) - 15mm", - top = "22mm", - bottom = "top(footnotes)", - }, - runningHead = { - left = "left(content)", - right = "right(content)", - top = "top(content) - 10mm", - bottom = "top(content) - 4mm", - }, - footnotes = { - left = "left(content)", - right = "right(content)", - height = "0", - bottom = "top(folio) - 5mm", - }, - folio = { - left = "left(content)", - right = "right(content)", - height = "5mm", - bottom = "bottom(page) - 12.5mm", - }, + id = "right", + firstContentFrame = "content", + frames = { + content = { + left = "left(page) + 22.5mm", + right = "right(page) - 15mm", + top = "22mm", + bottom = "top(footnotes)", + }, + runningHead = { + left = "left(content)", + right = "right(content)", + top = "top(content) - 10mm", + bottom = "top(content) - 4mm", + }, + footnotes = { + left = "left(content)", + right = "right(content)", + height = "0", + bottom = "top(folio) - 5mm", + }, + folio = { + left = "left(content)", + right = "right(content)", + height = "5mm", + bottom = "bottom(page) - 12.5mm", }, }, - } - ) + }, + }) end end diff --git a/scripts/series_sort.lua.in b/scripts/series_sort.lua.in index 8c02c9ba..0ab72415 100644 --- a/scripts/series_sort.lua.in +++ b/scripts/series_sort.lua.in @@ -3,8 +3,8 @@ local yaml = require("yaml") yaml.configure({ - load_nulls_as_nil = true, - load_numeric_scalars = false, + load_nulls_as_nil = true, + load_numeric_scalars = false, }) local PROJECT = os.getenv("PROJECT") @@ -13,62 +13,62 @@ local TARGETS = os.getenv("TARGETS") local BUILDDIR = os.getenv("BUILDDIR") -- luacheck: ignore dump -local function dump(...) - local arg = { ... } -- Avoid things that Lua stuffs in arg like args to self() - require("pl.pretty").dump(#arg == 1 and arg[1] or arg, "/dev/stderr") +local function dump (...) + local arg = { ... } -- Avoid things that Lua stuffs in arg like args to self() + require("pl.pretty").dump(#arg == 1 and arg[1] or arg, "/dev/stderr") end local booktitles = {} local books = { ... } -- arg has 0 and -1 keys that aren't the passed arguments -local status, seriesmeta = pcall(yaml.loadpath, PROJECT .. '.yml') +local status, seriesmeta = pcall(yaml.loadpath, PROJECT .. ".yml") local seriestitles = {} local seriesorders = {} if status and seriesmeta then - for _, title in ipairs(seriesmeta.seriestitles) do - table.insert(seriestitles, title.title) - seriesorders[title.title] = title.order - end + for _, title in ipairs(seriesmeta.seriestitles) do + table.insert(seriestitles, title.title) + seriesorders[title.title] = title.order + end else - for title in TARGETS:gmatch("%S+") do - table.insert(seriestitles, title) - seriesorders[title] = #seriesorders+1 - end + for title in TARGETS:gmatch("%S+") do + table.insert(seriestitles, title) + seriesorders[title] = #seriesorders + 1 + end end local fetchtitle = function (bookid) - if not booktitles[bookid] then - booktitles[bookid] = yaml.loadpath(bookid .. '.yml').title - end - return booktitles[bookid] + if not booktitles[bookid] then + booktitles[bookid] = yaml.loadpath(bookid .. ".yml").title + end + return booktitles[bookid] end local getorder = function (book) - if SORTORDER == "alphabetical" then - return book - end - local bookid = book:gsub("-.*", ""):gsub(BUILDDIR.."/", "") - for key,val in ipairs(seriestitles) do - if SORTORDER == "manual" then - if seriesorders[fetchtitle(bookid)] then - return seriesorders[fetchtitle(bookid)] + if SORTORDER == "alphabetical" then + return book + end + local bookid = book:gsub("-.*", ""):gsub(BUILDDIR .. "/", "") + for key, val in ipairs(seriestitles) do + if SORTORDER == "manual" then + if seriesorders[fetchtitle(bookid)] then + return seriesorders[fetchtitle(bookid)] + end + elseif SORTORDER == "meta" then + if val == fetchtitle(bookid) then + return key + end end - elseif SORTORDER == "meta" then - if val == fetchtitle(bookid) then - return key - end - end - end - return 1 -- TODO: add option for sorting by publish date + end + return 1 -- TODO: add option for sorting by publish date end local seriessort = function (a, b) - return getorder(a) < getorder(b) + return getorder(a) < getorder(b) end if SORTORDER ~= "none" then - table.sort(books, seriessort) + table.sort(books, seriessort) end print(table.concat(books, " ")) diff --git a/scripts/toc2breaks.lua.in b/scripts/toc2breaks.lua.in index 0bf82d01..1cc8db2c 100644 --- a/scripts/toc2breaks.lua.in +++ b/scripts/toc2breaks.lua.in @@ -7,7 +7,9 @@ local basename = arg[1] local path = arg[1] .. "/app/" .. arg[1] local tocfile = io.open(arg[2], "r") -if not tocfile then return false end +if not tocfile then + return false +end local doc = tocfile:read("*a") tocfile:close() @@ -19,12 +21,14 @@ local meta = yaml.loadpath(arg[3]) local share = "https://yayinlar.viachristus.com/" local infofile = io.open(arg[4], "w") -if not infofile then return false end +if not infofile then + return false +end local infow = function (str, endpar) - str = str or "" - endpar = endpar and "\n" or "" - infofile:write(str .. "\n" .. endpar) + str = str or "" + endpar = endpar and "\n" or "" + infofile:write(str .. "\n" .. endpar) end infow("TITLE:") @@ -34,12 +38,14 @@ infow("SUBTITLE:") infow(meta.subtitle, true) if meta.creator then - for _, v in ipairs(meta.creator) do - if v.role == "author" then meta.author = v.text end - end + for _, v in ipairs(meta.creator) do + if v.role == "author" then + meta.author = v.text + end + end end -infow("AUTHOR:" ) +infow("AUTHOR:") infow(meta.author, true) infow("ABSTRACT:") @@ -57,52 +63,52 @@ local labels = {} local breaks = {} if #toc > 0 then - -- Label the first chunk before we skip to the content - labels[1] = toc[1].label[1] - - -- Drop the first TOC entry, the top of the file will be 1 - table.remove(toc, 1) - - local lastpage = 1 - breaks = { 1 } - - -- Get a table of major (more that 2 pages apart) TOC entries - -- TODO: should this be ipairs()? - for _, tocentry in pairs(toc) do - if tocentry.level <= 2 then - local pageno = tonumber(tocentry.pageno) - if pageno > lastpage + 2 then - table.insert(breaks, pageno) - labels[#breaks] = tocentry.label[1] - lastpage = pageno - else - labels[#breaks] = tostring(labels[#breaks]) .. ", " .. tostring(tocentry.label[1]) + -- Label the first chunk before we skip to the content + labels[1] = toc[1].label[1] + + -- Drop the first TOC entry, the top of the file will be 1 + table.remove(toc, 1) + + local lastpage = 1 + breaks = { 1 } + + -- Get a table of major (more that 2 pages apart) TOC entries + -- TODO: should this be ipairs()? + for _, tocentry in pairs(toc) do + if tocentry.level <= 2 then + local pageno = tonumber(tocentry.pageno) + if pageno > lastpage + 2 then + table.insert(breaks, pageno) + labels[#breaks] = tocentry.label[1] + lastpage = pageno + else + labels[#breaks] = tostring(labels[#breaks]) .. ", " .. tostring(tocentry.label[1]) + end + end + end + + -- Convert the table to page rages suitable for pdftk + for i, v in pairs(breaks) do + if i ~= 1 then + breaks[i - 1] = breaks[i - 1] .. "-" .. v - 1 end - end - end - - -- Convert the table to page rages suitable for pdftk - for i, v in pairs(breaks) do - if i ~= 1 then - breaks[i-1] = breaks[i-1] .. "-" .. v - 1 - end - end - breaks[#breaks] = breaks[#breaks] .. "-end" + end + breaks[#breaks] = breaks[#breaks] .. "-end" end -- Output a list suitable for shell script parsing for i, v in pairs(breaks) do - local n = string.format("%03d", i - 1) - local out = basename .. "-uygulama-" .. n .. ".pdf" - local out2 = path .. "-uygulama-" .. n .. ".pdf" + local n = string.format("%03d", i - 1) + local out = basename .. "-uygulama-" .. n .. ".pdf" + local out2 = path .. "-uygulama-" .. n .. ".pdf" - -- Fieds expected by makefile to pass to pdftk - print(v, out) + -- Fieds expected by makefile to pass to pdftk + print(v, out) - -- Human readable info for copy/paste to the church app - infow("CHUNK " .. i - 1 .. ":") - infow(labels[i]) - infow(share .. out2, true) + -- Human readable info for copy/paste to the church app + infow("CHUNK " .. i - 1 .. ":") + infow(labels[i]) + infow(share .. out2, true) end infofile:close()