Changes

Jump to navigation Jump to search
1,560 bytes added ,  09:51, 22 May 2021
underscore hyphenation for SHA
</context>
=== Underscore Hyphenation for SHA ===
 
The following sample deals with underscore hyphenation for SHA output (works with ConTeXt versions from 2021.05.15 22:45).
 
<context mode="lmtx" source=yes>
\startluacode
function document.addfunnyhyphen(tfmdata)
local underscore = utf.byte("_")
local char = tfmdata.characters[underscore]
if not char then return end
tfmdata.characters[0xFE000] = {
width = 0,
height = 0,
depth = 0,
commands = {
{ "right", -char.width },
{ "down", char.depth },
{ "slot", 1, underscore },
}
}
end
 
utilities.sequencers.appendaction("aftercopyingcharacters",
"after","document.addfunnyhyphen")
 
local shared = {
start = 1,
length = 1,
before = utf.char(0xFE000),
after = nil,
left = false,
right = false,
}
 
local all = table.setmetatableindex({ }, function(t,k)
return shared
end)
 
languages.hyphenators.traditional.installmethod("sha",
function(dictionary,word,n)
return all
end)
\stopluacode
 
\definehyphenationfeatures
[sha]
[characters=all,
alternative=sha,
righthyphenchar="FE000]
 
\sethyphenationfeatures[sha]
\setuphyphenation[method=traditional]
 
\ctxlua{require("util-sha")}
\def\hashfivefile#1{%
\ctxlua{context(utilities.sha2.hash512("#1"))}}
 
\starttext
\startTEXpage[offset=1em, width=15em]
\hashfivefile{ConTeXt}
\stopTEXpage
\stoptext
</context>
=== See also ===
139

edits

Navigation menu