On 07/08/2017 01:32 PM, Hans Hagen wrote:
On 7/7/2017 10:28 PM, josephcanedo@gmail.com wrote:
A probably quick and dirty « solution », which consists in inserting a \discretionary node between each digit using some lua code. There are mostly likely better solutions for this.
"better" depends on how often such a trick is needed
Many thanks for your help, Hans and Joseph. I will play with your sample bellow to adapt it to the underscore hyphenation to the code provided here. Pablo
\startluacode
-- local shared = { -- start = 1, -- length = 1, -- left = false, -- right = false, -- }
local shared = { start = 1, length = 1, before = utf.char(0xB7), after = nil, left = false, right = false, }
-- languages.hyphenators.traditional.installmethod("sha", -- function(dictionary,word,n) -- local t = { } -- for i=1,#word do -- t[i] = shared -- end -- return t -- end -- )
-- or more efficient when used often:
-- local all = { } -- for i=1,512 do -- all[i] = shared -- end -- languages.hyphenators.traditional.installmethod("sha", -- function(dictionary,word,n) -- return all -- end -- )
-- or more obscure:
-- local all = table.setmetatableindex({ }, function(t,k) -- t[k] = shared -- return shared -- end) -- -- languages.hyphenators.traditional.installmethod("sha", -- function(dictionary,word,n) -- return all -- end -- )
-- or just (lua is fast enough anyway)
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]
% \unexpanded\def\sha#1% % {\begingroup % \sethyphenationfeatures[sha]% % #1% % \endgroup} % % \setuphyphenation[method=traditional]
\unexpanded\def\sha#1% {\begingroup \sethyphenationfeatures[sha]% \setuphyphenation[method=traditional]% #1% \endgroup}
\showframe
\starttext
\setupalign[tolerant,stretch]
\dorecurse {100} {% some sha \sha{8b2f3c087046c3943ace0dc4f958ef2138e58a51b40e% ef6fab6fa1aeb845cc257a410ab1b914bc399b4293f% 31c76fc2c73e5be5ea4d329f9e6820984688efec2} and }
\stoptext