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

sile-typesetter / sile / 4553559142

pending completion
4553559142

push

github

GitHub
Merge 899ea71f7 into fbfe5d402

118 of 118 new or added lines in 20 files covered. (100.0%)

8278 of 15423 relevant lines covered (53.67%)

6241.95 hits per line

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

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

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

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

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

34
function package:registerCommands ()
×
35

36
  self:registerCommand("pullquote:font", function (_, _)
×
37
  end, "The font chosen for the pullquote environment")
×
38

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

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

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

76
end
77

78
package.documentation = [[
79
\begin{document}
80
The \autodoc:environment{pullquote} environment formats longer quotations in an indented blockquote block with decorative quotation marks in the margins.
81

82
Here is some text set in a \autodoc:environment{pullquote} environment:
83

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

89
Optional values are available for:
90

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

98
If you want to specify what font the \autodoc:environment{pullquote} environment should use, you can redefine the \autodoc:command{\pullquote:font} command.
99
By default it will be the same as the surrounding document.
100
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}.
101
\end{document}
102
]]
×
103

104
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