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

sile-typesetter / sile / 9304060604

30 May 2024 02:07PM UTC coverage: 74.124% (-0.6%) from 74.707%
9304060604

push

github

alerque
style: Reformat Lua with stylua

8104 of 11995 new or added lines in 184 files covered. (67.56%)

15 existing lines in 11 files now uncovered.

12444 of 16788 relevant lines covered (74.12%)

7175.1 hits per line

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

79.17
/packages/chapterverse/init.lua
1
local base = require("packages.base")
1✔
2

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

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

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

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

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

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

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

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

91
return package
1✔
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