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

sile-typesetter / sile / 9409557472

07 Jun 2024 12:09AM UTC coverage: 69.448% (-4.5%) from 73.988%
9409557472

push

github

alerque
fix(build): Distribute vendored compat-5.3.c source file

12025 of 17315 relevant lines covered (69.45%)

6023.46 hits per line

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

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

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

6
function package:registerCommands ()
×
7
   self:registerCommand("unichar", function (_, content)
×
8
      local cp = content[1]
×
9
      if type(cp) ~= "string" then
×
10
         SU.error("Bad argument to \\unicode")
×
11
      end
12
      local hlist = SILE.typesetter.state.nodes
×
13
      local char = SU.utf8charfromcodepoint(cp)
×
14
      if
15
         #hlist > 1
×
16
         and hlist[#hlist].is_unshaped
×
17
         and pl.tablex.deepcompare(hlist[#hlist].options, SILE.font.loadDefaults({}))
×
18
      then
19
         -- Stack character with a preceeding unshaped node if its font is the
20
         -- same as the current one, so that combining characters (e.g. diacritics)
21
         -- and kerning works with \unichar'ed code points too.
22
         hlist[#hlist].text = hlist[#hlist].text .. char
×
23
      else
24
         SILE.typesetter:typeset(char)
×
25
      end
26
   end)
27
end
28

29
package.documentation = [[
30
\begin{document}
31
\use[module=packages.unichar]
32
SILE is Unicode compatible, and expects its input files to be in the UTF-8 encoding.
33
(The actual range of Unicode characters supported will depend on the supported ranges of the fonts that SILE is using to typeset.)
34
Some Unicode characters are hard to locate on a standard keyboard, and so are difficult to enter into SILE documents.
35

36
The \autodoc:package{unichar} package helps with this problem by providing the \autodoc:command{\unichar} command to enter Unicode codepoints.
37

38
\begin[type=autodoc:codeblock]{raw}
39
\unichar{U+263A}
40
\end{raw}
41

42
This produces: \font[family=Symbola]{\unichar{U+263A}}
43

44
If the argument to \autodoc:command{\unichar} begins with \code{U+}, \code{u+}, \code{0x}, or \code{0X}, then it is assumed to be a hexadecimal value.
45
Otherwise it is assumed to be a decimal codepoint.
46
\end{document}
47
]]
×
48

49
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