Changes

Jump to navigation Jump to search
1,116 bytes added ,  15:35, 5 October 2023
interleaving colons as a workaround
</context>
</ref>
 
=== Workaround with soft hyphens ===
As a workaround, a simpler way to break SHA sums in lines, but without any character would be (abusing both {{cmd|handletokens}} and {{cmd|softhyphen}}):
ef6fab6fa1aeb845cc257a410ab1b914bc399b4293f%
31c76fc2c73e5be5ea4d329f9e6820984688efec2}
\stopTEXpage
</context>
 
=== Another workaround interleaving colons ===
 
Another workaround that also helps to improve readability are interleaved colons every two characters. Of course you might change the number of chars without colons adding single dots to <code>str:match("..")</code>. Please, keep in mind that this will make line wrapping not easier in some places.
 
<context source="yes">
\startluacode
require("util-sha")
function document.coloniter(str)
local n = 0
for c in str:gmatch("..") do
if n > 0 then
context((":%s"):format(c))
else
context(c)
end
n = n + 1
end
end
\stopluacode
 
\unexpanded\def\hsa[#1]%
{{\tt\hyphenatedurl%
{\ctxlua{document.coloniter(utilities.sha2.hash512("#1"))}}}}
 
\unexpanded\def\hsafile[#1]%
{\doiffileelse{#1}{{\tt\hyphenatedurl
{\ctxlua{document.coloniter(utilities.sha2.hash512(io.loaddata("#1")))}}}}
{{\bfd\color[red]{\type{#1} not available!!!}}}}
 
\starttext
\startTEXpage[offset=1dk]
This is a sequence: \hsa[This is a sequence].
\blank
This is a file: \hsafile[\jobname.tex]
\stopTEXpage
</context>
139

edits

Navigation menu