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

sile-typesetter / sile / 9304049654

30 May 2024 02:12PM UTC coverage: 60.021% (-14.7%) from 74.707%
9304049654

push

github

web-flow
Merge 1a26b4f22 into a1fd105f8

6743 of 12900 new or added lines in 186 files covered. (52.27%)

347 existing lines in 49 files now uncovered.

10311 of 17179 relevant lines covered (60.02%)

3307.34 hits per line

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

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

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

6
local typesetMark = function (open, setback, scale, color, mark)
NEW
7
   SILE.settings:temporarily(function ()
×
NEW
8
      SILE.call("pullquote:mark-font")
×
NEW
9
      SILE.call("raise", { height = -(open and (scale + 1) or scale) .. "ex" }, function ()
×
NEW
10
         SILE.settings:set("font.size", SILE.settings:get("font.size") * scale)
×
NEW
11
         SILE.call("color", { color = color }, function ()
×
NEW
12
            if open then
×
NEW
13
               SILE.typesetter:pushGlue({ width = -setback })
×
NEW
14
               SILE.call("rebox", { width = setback, height = 0 }, { mark })
×
15
            else
NEW
16
               SILE.typesetter:pushGlue(SILE.types.node.hfillglue())
×
NEW
17
               local hbox = SILE.typesetter:makeHbox({ mark }) -- for measuring
×
NEW
18
               SILE.typesetter:pushGlue({ width = setback - hbox.width })
×
NEW
19
               SILE.call("rebox", { width = hbox.width, height = 0 }, { mark })
×
NEW
20
               SILE.typesetter:pushGlue({ width = -setback })
×
21
            end
22
         end)
23
      end)
24
   end)
25
end
26

UNCOV
27
function package:_init ()
×
NEW
28
   base._init(self)
×
NEW
29
   self:loadPackage("color")
×
NEW
30
   self:loadPackage("raiselower")
×
NEW
31
   self:loadPackage("rebox")
×
32
end
33

UNCOV
34
function package:registerCommands ()
×
NEW
35
   self:registerCommand("pullquote:font", function (_, _) end, "The font chosen for the pullquote environment")
×
36

NEW
37
   self:registerCommand("pullquote:author-font", function (_, _)
×
NEW
38
      SILE.settings:set("font.style", "italic")
×
NEW
39
   end, "The font style with which to typeset the author attribution.")
×
40

NEW
41
   self:registerCommand("pullquote:mark-font", function (_, _)
×
NEW
42
      SILE.settings:set("font.family", "Libertinus Serif")
×
NEW
43
   end, "The font from which to pull the quotation marks.")
×
44

NEW
45
   self:registerCommand(
×
46
      "pullquote",
47
      function (options, content)
NEW
48
         SILE.typesetter:leaveHmode()
×
NEW
49
         local author = options.author or nil
×
NEW
50
         local scale = options.scale or 3
×
NEW
51
         local color = options.color or "#999999"
×
NEW
52
         SILE.settings:temporarily(function ()
×
NEW
53
            SILE.call("pullquote:font")
×
NEW
54
            local setback = SU.cast("length", options.setback or "2em"):absolute()
×
NEW
55
            SILE.settings:set("document.rskip", SILE.types.node.glue(setback))
×
NEW
56
            SILE.settings:set("document.lskip", SILE.types.node.glue(setback))
×
NEW
57
            SILE.call("noindent")
×
NEW
58
            typesetMark(true, setback, scale, color, "“")
×
NEW
59
            SILE.call("indent")
×
NEW
60
            SILE.process(content)
×
NEW
61
            typesetMark(false, setback, scale, color, "”")
×
NEW
62
            if author then
×
NEW
63
               SILE.settings:temporarily(function ()
×
NEW
64
                  SILE.typesetter:leaveHmode()
×
NEW
65
                  SILE.call("pullquote:author-font")
×
NEW
66
                  SILE.call("raggedleft", {}, function ()
×
NEW
67
                     SILE.typesetter:typeset("— " .. author)
×
68
                  end)
69
               end)
70
            else
NEW
71
               SILE.call("par")
×
72
            end
73
         end)
74
      end,
NEW
75
      "Typesets its contents in a formatted blockquote with decorative quotation\
×
NEW
76
        marks in the margins."
×
77
   )
78
end
79

80
package.documentation = [[
81
\begin{document}
82
The \autodoc:package{pullquote} package formats longer quotations in an indented blockquote block with decorative quotation marks in the margins.
83
Here is some text set in a \autodoc:environment{pullquote} environment:
84

85
\begin[author=Anatole France]{pullquote}%
86
An education is not how much you have committed to memory, or even how much you know.
87
It is being able to differentiate between what you do know and what you do not know.
88
\end{pullquote}
89

90
Optional values are available for:
91

92
\begin{itemize}
93
\item{\autodoc:parameter{author} to add an attribution line}
94
\item{\autodoc:parameter{setback} to set the bilateral margins around the block}
95
\item{\autodoc:parameter{color} to change the color of the quote marks}
96
\item{\autodoc:parameter{scale} to change the relative size of the quote marks}
97
\end{itemize}
98

99
If you want to specify what font the \autodoc:environment{pullquote} environment should use, you can redefine the \autodoc:command{\pullquote:font} command.
100
By default it will be the same as the surrounding document.
101
The font style used for the attribution line can likewise be set redefining \autodoc:command{\pullquote:author-font}, and the font used for the quote marks can be set redefining \autodoc:command{\pullquote:mark-font}.
102
\end{document}
UNCOV
103
]]
×
104

UNCOV
105
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