• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 7232859119

16 Dec 2023 03:49PM UTC coverage: 66.878% (-7.7%) from 74.62%
7232859119

push

github

web-flow
Merge 05d75c2a3 into 8686730e4

0 of 4 new or added lines in 1 file covered. (0.0%)

1201 existing lines in 56 files now uncovered.

10550 of 15775 relevant lines covered (66.88%)

3347.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/chapterverse/init.lua
UNCOV
1
local base = require("packages.base")
×
2

UNCOV
3
local package = pl.class(base)
×
UNCOV
4
package._name = "chapterverse"
×
5

UNCOV
6
function package:_init ()
×
UNCOV
7
  base._init(self)
×
UNCOV
8
  self:loadPackage("infonode")
×
UNCOV
9
  if not SILE.scratch.chapterverse then
×
UNCOV
10
    SILE.scratch.chapterverse = {}
×
11
  end
12
end
13

UNCOV
14
function package:registerCommands ()
×
15

UNCOV
16
  self:registerCommand("save-book-title", function (_, content)
×
UNCOV
17
    SU.debug("chapterverse", "book:", content[1])
×
UNCOV
18
    SILE.scratch.chapterverse.book = content[1]
×
19
  end)
20

UNCOV
21
  self:registerCommand("save-chapter-number", function (_, content)
×
UNCOV
22
    SU.debug("chapterverse", "chapter:", content[1])
×
UNCOV
23
    SILE.scratch.chapterverse.chapter = content[1]
×
24
  end)
25

UNCOV
26
  self:registerCommand("save-verse-number", function (_, content)
×
UNCOV
27
    SU.debug("chapterverse", "verse:", content[1])
×
UNCOV
28
    SILE.scratch.chapterverse.verse = content[1]
×
UNCOV
29
    local ref = {
×
30
      book = SILE.scratch.chapterverse.book,
31
      chapter = SILE.scratch.chapterverse.chapter,
UNCOV
32
      verse = SILE.scratch.chapterverse.verse
×
33
    }
UNCOV
34
    SU.debug("chapterverse", "ref:", ref)
×
UNCOV
35
    SILE.call("info", { category = "references", value = ref }, {})
×
36
  end)
37

UNCOV
38
  self:registerCommand("first-reference", function (_, _)
×
UNCOV
39
    local refs = SILE.scratch.info.thispage.references
×
UNCOV
40
    SU.debug("chapterverse", "first-reference:", SILE.scratch.info)
×
UNCOV
41
    if refs then
×
UNCOV
42
      SU.debug("chapterverse", "first-reference:", refs[1])
×
UNCOV
43
      SILE.call("format-reference", {}, refs[1])
×
44
    else
45
      SU.debug("chapterverse", "first-reference: none")
×
46
    end
47
  end)
48

UNCOV
49
  self:registerCommand("last-reference", function (options, _)
×
UNCOV
50
    local refs = SILE.scratch.info.thispage.references
×
UNCOV
51
    if refs then
×
UNCOV
52
      SU.debug("chapterverse", "last-reference:", refs[#(refs)])
×
UNCOV
53
      SILE.call("format-reference", options, refs[#(refs)])
×
54
    else
55
      SU.debug("chapterverse", "last-reference: none")
×
56
    end
57
  end)
58

UNCOV
59
  self:registerCommand("format-reference", function (options, content)
×
60
    if type(options.showbook) == "nil" then options.showbook = true end
×
61
    SU.debug("chapterverse", "formatting:", content)
×
62
    local ref
63
    if content.book and options.showbook then
×
64
      ref = tostring(content.book) .. " " .. tostring(content.chapter) .. ":" .. tostring(content.verse)
×
65
    else
66
      ref = tostring(content.chapter) .. ":" .. tostring(content.verse)
×
67
    end
68
    SU.debug("chapterverse", "formatting:", ref)
×
69
    SILE.typesetter:typeset(ref)
×
70
  end)
71

72
end
73

74
package.documentation = [[
75
\begin{document}
76
The \autodoc:package{chapterverse} package is designed as a helper package for book classes which deal with versified content such as scriptures.
77
It provides commands which will generally be called by the higher-level \autodoc:command[check=false]{\verse} and \autodoc:command[check=false]{\chapter} (or moral equivalent) commands of the classes which handle this kind of content:
78

79
\begin{itemize}
80
\item{\autodoc:command{\save-book-title} takes its argument and squirrels it away as the current book name.}
81
\item{\autodoc:command{\save-chapter-number} and \autodoc:command{\save-verse-number} does the same but for the chapter and verse reference respectively.}
82
\item{\autodoc:command{\format-reference} is expected to be called from Lua code with a content table of \code{\{book = ..., chapter = ..., verse = ...\}} and typesets the reference in the form \code{cc:vv}.
83
      If the parameter \autodoc:parameter{showbook=true} is given then the book name is also output.
84
      (You can override this command to output your references in a different format.)}
85
\item{\autodoc:command{\first-reference} and \autodoc:command{\last-reference} typeset (using \autodoc:command{\format-reference}) the first reference on the page and the last reference on the page respectively.
86
      This is helpful for running headers.}
87
\end{itemize}
88
\end{document}
UNCOV
89
]]
×
90

UNCOV
91
return package
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc