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

sile-typesetter / sile / 9409557472

07 Jun 2024 12:09AM UTC coverage: 69.448% (-4.5%) from 73.988%
9409557472

push

github

alerque
fix(build): Distribute vendored compat-5.3.c source file

12025 of 17315 relevant lines covered (69.45%)

6023.46 hits per line

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

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

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

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

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

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

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

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

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

58
   self:registerCommand("format-reference", function (options, content)
×
59
      if type(options.showbook) == "nil" then
×
60
         options.showbook = true
×
61
      end
62
      SU.debug("chapterverse", "formatting:", content)
×
63
      local ref
64
      if content.book and options.showbook then
×
65
         ref = tostring(content.book) .. " " .. tostring(content.chapter) .. ":" .. tostring(content.verse)
×
66
      else
67
         ref = tostring(content.chapter) .. ":" .. tostring(content.verse)
×
68
      end
69
      SU.debug("chapterverse", "formatting:", ref)
×
70
      SILE.typesetter:typeset(ref)
×
71
   end)
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}
89
]]
×
90

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

© 2025 Coveralls, Inc