From: Pablo Rodriguez <oinos@gmx.es>
To: ntg-context@ntg.nl
Subject: Re: how to hyphenate SHA512?
Date: Mon, 10 Jul 2017 12:44:08 +0200 [thread overview]
Message-ID: <8359f88c-82f4-7dc0-5f8b-38e440e43af5@gmx.es> (raw)
In-Reply-To: <17536b2f-f433-37ea-fea6-1d0f73e63128@wxs.nl>
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
___________________________________________________________________________________
prev parent reply other threads:[~2017-07-10 10:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 10:00 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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8359f88c-82f4-7dc0-5f8b-38e440e43af5@gmx.es \
--to=oinos@gmx.es \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).