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

sile-typesetter / sile / 6713098919

31 Oct 2023 10:21PM UTC coverage: 52.831% (-21.8%) from 74.636%
6713098919

push

github

web-flow
Merge d0a2a1ee9 into b185d4972

45 of 45 new or added lines in 3 files covered. (100.0%)

8173 of 15470 relevant lines covered (52.83%)

6562.28 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

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

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

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

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

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

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}
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