* how to hyphenate SHA512?
@ 2017-07-06 10:00 Pablo Rodriguez
2017-07-07 20:28 ` josephcanedo
0 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2017-07-06 10:00 UTC (permalink / raw)
To: mailing list for ConTeXt users
Dear list,
I have the following sample:
\starttext
\hsize\zeropoint
hyphenation
8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
\stoptext
I plan to use underscore hyphenation. How can I get the SHA512 string
hyphenated in any of its points?
Many thanks for your help,
Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to hyphenate SHA512?
2017-07-06 10:00 how to hyphenate SHA512? Pablo Rodriguez
@ 2017-07-07 20:28 ` josephcanedo
2017-07-08 6:56 ` Pablo Rodriguez
2017-07-08 11:32 ` Hans Hagen
0 siblings, 2 replies; 7+ messages in thread
From: josephcanedo @ 2017-07-07 20:28 UTC (permalink / raw)
To: Pablo Rodriguez, mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1837 bytes --]
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.
Joseph
\startluacode
function sha(s)
local out = {}
for i = 1, s:len() do
out[#out + 1] = s:sub(i, i)
end
context(table.concat(out, '\\discretionary{_}{}{}'))
end
\stopluacode
\starttext
% \hsize\zeropoint
\hyphenation
%%8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
%%7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
\ctxlua{sha([[8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc257a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2]])}
\stoptext
De : Pablo Rodriguez
Envoyé le :jeudi 6 juillet 2017 12:00
À : mailing list for ConTeXt users
Objet :[NTG-context] how to hyphenate SHA512?
Dear list,
I have the following sample:
\starttext
\hsize\zeropoint
hyphenation
8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
\stoptext
I plan to use underscore hyphenation. How can I get the SHA512 string
hyphenated in any of its points?
Many thanks for your help,
Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 4853 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to hyphenate SHA512?
2017-07-07 20:28 ` josephcanedo
@ 2017-07-08 6:56 ` Pablo Rodriguez
2017-07-08 8:20 ` josephcanedo
2017-07-08 11:32 ` Hans Hagen
1 sibling, 1 reply; 7+ messages in thread
From: Pablo Rodriguez @ 2017-07-08 6:56 UTC (permalink / raw)
To: ntg-context
Many thanks for your reply, Joseph.
The underscore I want to use should be placed below the previous
character, such as in (code from Hans):
\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")
\stopluacode
\definehyphenationfeatures
[underscore]
[righthyphenchar="FE000]
\setuphyphenation
[method=traditional]
\sethyphenationfeatures
[underscore]
\starttext
\hsize\zeropoint
hyphenation
\stoptext
Is there no way to define a language that hyphenates any pair of characters?
Many thanks for your help,
Pablo
On 07/07/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.
>
> Joseph
>
> \startluacode
>
> function sha(s)
> local out = {}
> for i = 1, s:len() do
> out[#out + 1] = s:sub(i, i)
> end
> context(table.concat(out, '\\discretionary{_}{}{}'))
> end
>
> \stopluacode
>
> \starttext
>
> \hyphenation
>
> \ctxlua{sha([[8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc257a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2]])}
>
> \stoptext
>
>
> *De : *Pablo Rodriguez <mailto:oinos@gmx.es>
> *Envoyé le :*jeudi 6 juillet 2017 12:00
> *À : *mailing list for ConTeXt users <mailto:ntg-context@ntg.nl>
> *Objet :*[NTG-context] how to hyphenate SHA512?
>
> Dear list,
>
> I have the following sample:
>
> \starttext
> \hsize\zeropoint
> hyphenation
>
> 8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
> 7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
> \stoptext
>
> I plan to use underscore hyphenation. How can I get the SHA512 string
> hyphenated in any of its points?
>
> Many thanks for your help,
>
> Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to hyphenate SHA512?
2017-07-08 6:56 ` Pablo Rodriguez
@ 2017-07-08 8:20 ` josephcanedo
2017-07-08 11:34 ` Hans Hagen
0 siblings, 1 reply; 7+ messages in thread
From: josephcanedo @ 2017-07-08 8:20 UTC (permalink / raw)
To: Pablo Rodriguez, ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 3549 bytes --]
If I am not mistaken SHA is only hexadecimal digits, so you probably need only to have a « language » that hyphenates between any pair of those. Should be much simpler I guess, but I do not really know how to add such setting I am afraid.
Joseph
De : Pablo Rodriguez
Envoyé le :samedi 8 juillet 2017 08:56
À : ntg-context@ntg.nl
Objet :Re: [NTG-context] how to hyphenate SHA512?
Many thanks for your reply, Joseph.
The underscore I want to use should be placed below the previous
character, such as in (code from Hans):
\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")
\stopluacode
\definehyphenationfeatures
[underscore]
[righthyphenchar="FE000]
\setuphyphenation
[method=traditional]
\sethyphenationfeatures
[underscore]
\starttext
\hsize\zeropoint
hyphenation
\stoptext
Is there no way to define a language that hyphenates any pair of characters?
Many thanks for your help,
Pablo
On 07/07/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.
>
> Joseph
>
> \startluacode
>
> function sha(s)
> local out = {}
> for i = 1, s:len() do
> out[#out + 1] = s:sub(i, i)
> end
> context(table.concat(out, '\\discretionary{_}{}{}'))
> end
>
> \stopluacode
>
> \starttext
>
> \hyphenation
>
> \ctxlua{sha([[8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc257a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2]])}
>
> \stoptext
>
>
> *De : *Pablo Rodriguez <mailto:oinos@gmx.es>
> *Envoyé le :*jeudi 6 juillet 2017 12:00
> *À : *mailing list for ConTeXt users <mailto:ntg-context@ntg.nl>
> *Objet :*[NTG-context] how to hyphenate SHA512?
>
> Dear list,
>
> I have the following sample:
>
> \starttext
> \hsize\zeropoint
> hyphenation
>
> 8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
> 7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
> \stoptext
>
> I plan to use underscore hyphenation. How can I get the SHA512 string
> hyphenated in any of its points?
>
> Many thanks for your help,
>
> Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
[-- Attachment #1.2: Type: text/html, Size: 8522 bytes --]
[-- Attachment #2: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to hyphenate SHA512?
2017-07-07 20:28 ` josephcanedo
2017-07-08 6:56 ` Pablo Rodriguez
@ 2017-07-08 11:32 ` Hans Hagen
2017-07-10 10:44 ` Pablo Rodriguez
1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2017-07-08 11:32 UTC (permalink / raw)
To: mailing list for ConTeXt users, josephcanedo, Pablo Rodriguez
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
\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
> \startluacode
>
> function sha(s)
>
> local out = {}
>
> for i = 1, s:len() do
>
> out[#out + 1] = s:sub(i, i)
>
> end
>
> context(table.concat(out, '\\discretionary{_}{}{}'))
>
> end
>
> \stopluacode
>
> \starttext
>
> % \hsize\zeropoint
>
> \hyphenation
>
> %%8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
>
> %%7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
>
> \ctxlua{sha([[8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc257a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2]])}
>
> \stoptext
>
> *De : *Pablo Rodriguez <mailto:oinos@gmx.es>
> *Envoyé le :*jeudi 6 juillet 2017 12:00
> *À : *mailing list for ConTeXt users <mailto:ntg-context@ntg.nl>
> *Objet :*[NTG-context] how to hyphenate SHA512?
>
> Dear list,
>
> I have the following sample:
>
> \starttext
>
> \hsize\zeropoint
>
> hyphenation
>
> 8b2f3c087046c3943ace0dc4f958ef2138e58a51b40eef6fab6fa1aeb845cc25%
>
> 7a410ab1b914bc399b4293f31c76fc2c73e5be5ea4d329f9e6820984688efec2
>
> \stoptext
>
> I plan to use underscore hyphenation. How can I get the SHA512 string
>
> hyphenated in any of its points?
>
> Many thanks for your help,
>
> Pablo
>
> --
>
> http://www.ousia.tk
>
> ___________________________________________________________________________________
>
> If your question is of interest to others as well, please add an entry
> to the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
> webpage : http://www.pragma-ade.nl / http://context.aanhet.net
>
> archive : https://bitbucket.org/phg/context-mirror/commits/
>
> wiki : http://contextgarden.net
>
> ___________________________________________________________________________________
>
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : http://www.pragma-ade.nl / http://context.aanhet.net
> archive : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
>
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to hyphenate SHA512?
2017-07-08 8:20 ` josephcanedo
@ 2017-07-08 11:34 ` Hans Hagen
0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen @ 2017-07-08 11:34 UTC (permalink / raw)
To: mailing list for ConTeXt users, josephcanedo, Pablo Rodriguez
On 7/8/2017 10:20 AM, josephcanedo@gmail.com wrote:
> If I am not mistaken SHA is only hexadecimal digits, so you probably
> need only to have a « language » that hyphenates between any pair of
> those. Should be much simpler I guess, but I do not really know how to
> add such setting I am afraid.
you can cvreate a pattern for letters but the digits are a problem as
they conflict with the way patterns are defined
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: how to hyphenate SHA512?
2017-07-08 11:32 ` Hans Hagen
@ 2017-07-10 10:44 ` Pablo Rodriguez
0 siblings, 0 replies; 7+ messages in thread
From: Pablo Rodriguez @ 2017-07-10 10:44 UTC (permalink / raw)
To: ntg-context
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
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-07-10 10:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-06 10:00 how to hyphenate SHA512? Pablo Rodriguez
2017-07-07 20:28 ` josephcanedo
2017-07-08 6:56 ` Pablo Rodriguez
2017-07-08 8:20 ` josephcanedo
2017-07-08 11:34 ` Hans Hagen
2017-07-08 11:32 ` Hans Hagen
2017-07-10 10:44 ` Pablo Rodriguez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).