• 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/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

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

24
end
25

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

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

35
\begin[type=autodoc:codeblock]{raw}
36
\unichar{U+263A}
37
\end{raw}
38

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

41
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.
42
Otherwise it is assumed to be a decimal codepoint.
43
\end{document}
44
]]
×
45

46
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