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

sile-typesetter / sile / 11899102988

18 Nov 2024 06:50PM UTC coverage: 61.332% (-10.4%) from 71.755%
11899102988

push

github

alerque
style(tooling): Restyle Lua code with stylua

0 of 1 new or added line in 1 file covered. (0.0%)

1869 existing lines in 60 files now uncovered.

11228 of 18307 relevant lines covered (61.33%)

4965.14 hits per line

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

26.32
/packages/tate/init.lua
1
local base = require("packages.base")
2✔
2

3
local package = pl.class(base)
2✔
4
package._name = "tate"
2✔
5

6
SILE.tateFramePrototype = pl.class(SILE.framePrototype)
4✔
7
SILE.tateFramePrototype.direction = "TTB-RTL"
2✔
8

9
SILE.tateFramePrototype.enterHooks = {
2✔
10
   function (_, typesetter)
11
      SILE.typesetters.tate:cast(typesetter)
2✔
12
   end,
13
}
2✔
14

15
SILE.tateFramePrototype.leaveHooks = {
2✔
16
   function (_, typesetter)
17
      SILE.typesetters.base:cast(typesetter)
1✔
18
   end,
19
}
2✔
20

21
SILE.newTateFrame = function (spec)
2✔
22
   return SILE.newFrame(spec, SILE.tateFramePrototype)
×
23
end
24

25
local outputLatinInTate = function (self, typesetter, line)
26
   -- My baseline moved
UNCOV
27
   typesetter.frame:advanceWritingDirection(SILE.types.measurement("-0.5zw"))
×
UNCOV
28
   typesetter.frame:advancePageDirection(SILE.types.measurement("0.25zw"))
×
29

UNCOV
30
   local vorigin = -typesetter.frame.state.cursorY
×
UNCOV
31
   self:oldOutputYourself(typesetter, line)
×
UNCOV
32
   typesetter.frame.state.cursorY = -vorigin
×
UNCOV
33
   typesetter.frame:advanceWritingDirection(self:lineContribution())
×
34
   -- My baseline moved
UNCOV
35
   typesetter.frame:advanceWritingDirection(SILE.types.measurement("0.5zw"))
×
UNCOV
36
   typesetter.frame:advancePageDirection(-SILE.types.measurement("0.25zw"))
×
37
end
38

39
local outputTateChuYoko = function (self, typesetter, line)
40
   -- My baseline moved
41
   local em = SILE.types.measurement("1zw")
×
42
   typesetter.frame:advanceWritingDirection(-em + em / 4 - self:lineContribution() / 2)
×
43
   typesetter.frame:advancePageDirection(2 * self.height - self.width / 2)
×
44
   self:oldOutputYourself(typesetter, line)
×
45
   typesetter.frame:advanceWritingDirection(-self:lineContribution() * 1.5 + self.height * 3 / 4)
×
46
end
47

48
function package:registerCommands ()
2✔
49
   self:registerCommand("tate-frame", function (options, _)
6✔
50
      SILE.documentState.thisPageTemplate.frames[options.id] = SILE.newTateFrame(options)
×
51
   end, "Declares (or re-declares) a frame on this page.")
3✔
52

53
   -- Eventually will be automatically called by script detection, but for now
54
   -- called manually
55
   self:registerCommand("latin-in-tate", function (_, content)
6✔
UNCOV
56
      if SILE.typesetter.frame:writingDirection() ~= "TTB" then
×
57
         return SILE.process(content)
×
58
      end
59
      local nodes
UNCOV
60
      local oldT = SILE.typesetter
×
UNCOV
61
      local prevDirection = oldT.frame.direction
×
UNCOV
62
      self:loadPackage("rotate")
×
UNCOV
63
      SILE.settings:temporarily(function ()
×
UNCOV
64
         local latinTypesetter = pl.class(SILE.typesetters.base)
×
UNCOV
65
         local dummyFrame = pl.class(SILE.framePrototype)
×
66
         dummyFrame.init = function (f)
67
            f.state = {}
×
68
         end
69
         latinTypesetter.initFrame = function (typesetter, frame)
UNCOV
70
            typesetter.frame = frame
×
71
         end
UNCOV
72
         local frame = dummyFrame({}, true)
×
UNCOV
73
         SILE.typesetter = latinTypesetter(frame)
×
UNCOV
74
         SILE.settings:set("document.language", "und")
×
UNCOV
75
         SILE.settings:set("font.direction", "LTR")
×
UNCOV
76
         SILE.process(content)
×
UNCOV
77
         nodes = SILE.typesetter.state.nodes
×
UNCOV
78
         SILE.typesetter:shapeAllNodes(nodes)
×
UNCOV
79
         SILE.typesetter.frame.direction = prevDirection
×
80
      end)
UNCOV
81
      SILE.typesetter = oldT
×
UNCOV
82
      SILE.typesetter:pushGlue({
×
83
         width = SILE.types.length("0.5zw", "0.25zw", "0.25zw"):absolute(),
84
      })
UNCOV
85
      for i = 1, #nodes do
×
UNCOV
86
         if SILE.typesetter.frame:writingDirection() ~= "TTB" or nodes[i].is_glue then
×
UNCOV
87
            SILE.typesetter:pushHorizontal(nodes[i])
×
UNCOV
88
         elseif nodes[i]:lineContribution():tonumber() > 0 then
×
UNCOV
89
            local hbox = SILE.call("hbox", {}, function ()
×
UNCOV
90
               SILE.typesetter:pushHorizontal(nodes[i])
×
91
            end)
92
            -- Turn off all complex flags.
UNCOV
93
            for j = 1, #hbox.value do
×
UNCOV
94
               for k = 1, #hbox.value[j].nodes do
×
UNCOV
95
                  hbox.value[j].nodes[k].value.complex = false
×
96
               end
97
            end
UNCOV
98
            hbox.oldOutputYourself = hbox.outputYourself
×
UNCOV
99
            hbox.outputYourself = outputLatinInTate
×
100
         end
101
      end
102
   end, "Typeset rotated Western text in vertical Japanese")
3✔
103

104
   self:registerCommand("tate-chu-yoko", function (_, content)
6✔
105
      if SILE.typesetter.frame:writingDirection() ~= "TTB" then
×
106
         return SILE.process(content)
×
107
      end
108
      -- SILE.typesetter:pushGlue({
109
      --   width = SILE.types.length.new({length = SILE.toPoints("0.5zw"),
110
      --                            stretch = SILE.toPoints("0.25zw"),
111
      --                             shrink = SILE.toPoints("0.25zw")
112
      --                           })
113
      -- })
114
      SILE.settings:temporarily(function ()
×
115
         SILE.settings:set("document.language", "und")
×
116
         SILE.settings:set("font.direction", "LTR")
×
117
         SILE.call("rotate", { angle = -90 }, function ()
×
118
            local hbox = SILE.call("hbox", {}, content)
×
119
            hbox.misfit = true
×
120
            hbox.oldOutputYourself = hbox.outputYourself
×
121
            hbox.outputYourself = outputTateChuYoko
×
122
         end)
123
      end)
124
      -- SILE.typesetter:pushGlue({
125
      --   width = SILE.types.length.new({length = SILE.toPoints("0.5zw"),
126
      --                            stretch = SILE.toPoints("0.25zw"),
127
      --                             shrink = SILE.toPoints("0.25zw")
128
      --                           })
129
      -- })
130
   end)
131
end
132

133
package.documentation = [[
134
\begin{document}
135
The \autodoc:package{tate} package provides support for Japanese vertical typesetting.
136
It allows for the definition of vertical-oriented frames, as well as for two specific typesetting techniques required in vertical documents: \autodoc:command{\latin-in-tate} typesets its content as Latin text rotated 90 degrees, and \autodoc:command{\tate-chu-yoko} places (Latin) text horizontally within a single grid-square of the vertical \em{hanmen}.
137
\end{document}
138
]]
2✔
139

140
return package
2✔
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