summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/uninormalize/uninormalize.sty
blob: 4e1e4b15716e06e0d4753c1eaa406c3db4ddfcc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
\ProvidesPackage{uninormalize}
\RequirePackage{luatexbase}
\RequirePackage{luacode}
\RequirePackage{kvoptions}
\DeclareBoolOption[true]{nodes}
\DeclareBoolOption[true]{buffer}
\DeclareBoolOption{debug}
\ProcessKeyvalOptions*
\ifuninormalize@nodes
  \luaexec{processnodes=true}
\fi
\ifuninormalize@buffer
  \luaexec{processbuffer=true}
\fi
\ifuninormalize@debug
  \luaexec{uninormalize_debug = true}
\fi
\begin{luacode*}
local normalize = require "unicode-normalize"
if processnodes==true then
  print "[uninormalize] process nodes on"
  luatexbase.add_to_callback("pre_linebreak_filter",normalize.nodes, "normalize unicode")
  luatexbase.add_to_callback("hpack_filter",normalize.nodes, "normalize unicode")
end
if processbuffer== true then
  print "[uninormalize] process buffer on"
  luatexbase.add_to_callback("process_input_buffer", normalize.buffer," normalize unicode")
end
if uninormalize_debug then
  normalize.debug = true
end
\end{luacode*}


\endinput