* Bug in verbatim wrapping examples on wiki
@ 2023-02-04 6:49 Hugo Landau via ntg-context
2023-02-04 9:37 ` Pablo Rodriguez via ntg-context
2023-02-15 18:35 ` Pablo Rodriguez via ntg-context
0 siblings, 2 replies; 8+ messages in thread
From: Hugo Landau via ntg-context @ 2023-02-04 6:49 UTC (permalink / raw)
To: ntg-context; +Cc: Hugo Landau
On this page of the wiki there is an example for wrapping long words,
like long hexadecimal strings:
https://wiki.contextgarden.net/Wrapping
This example is buggy because it deletes one character at the point that
it is wrapped.
In the example given, running context turns '257a410' into '257410'.
The DNA example below it exhibits the same problem.
Anyone have a solution?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-04 6:49 Bug in verbatim wrapping examples on wiki Hugo Landau via ntg-context
@ 2023-02-04 9:37 ` Pablo Rodriguez via ntg-context
2023-02-05 11:32 ` Pablo Rodriguez via ntg-context
2023-02-15 18:35 ` Pablo Rodriguez via ntg-context
1 sibling, 1 reply; 8+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-02-04 9:37 UTC (permalink / raw)
To: Hugo Landau via ntg-context; +Cc: Pablo Rodriguez
On 2/4/23 07:49, Hugo Landau via ntg-context wrote:
> On this page of the wiki there is an example for wrapping long words,
> like long hexadecimal strings:
>
> https://wiki.contextgarden.net/Wrapping
>
> This example is buggy because it deletes one character at the point that
> it is wrapped.
>
> Anyone have a solution?
Many thanks for your report, Hugo.
I use this code from time to time and I totally overlooked this.
Have you checked all options that the sample contains?
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-04 9:37 ` Pablo Rodriguez via ntg-context
@ 2023-02-05 11:32 ` Pablo Rodriguez via ntg-context
2023-02-05 11:50 ` Floris van Manen via ntg-context
2023-02-05 12:13 ` Hans Hagen via ntg-context
0 siblings, 2 replies; 8+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-02-05 11:32 UTC (permalink / raw)
To: Pablo Rodriguez via ntg-context; +Cc: Pablo Rodriguez
On 2/4/23 10:37, Pablo Rodriguez via ntg-context wrote:
> On 2/4/23 07:49, Hugo Landau via ntg-context wrote:
>> On this page of the wiki there is an example for wrapping long words,
>> like long hexadecimal strings:
>>
>> https://wiki.contextgarden.net/Wrapping
>>
>> This example is buggy because it deletes one character at the point that
>> it is wrapped.
>>
>> Anyone have a solution?
>
> Many thanks for your report, Hugo.
>
> I use this code from time to time and I totally overlooked this.
>
> Have you checked all options that the sample contains?
Hans,
I have just checked that these line breakings loose a character in all
options.
The next sample displays the issue clearly:
\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}
\starttext
\hyphenatedword{\sha{8b2f3c087046c3943ace0dc4f958ef2138e58a51b40e%
ef6fab6fa1aeb845cc257a410ab1b914bc399b4293f%
31c76fc2c73e5be5ea4d329f9e6820984688efec2}}
\stoptext
Are we missing something or is this a bug?
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-05 11:32 ` Pablo Rodriguez via ntg-context
@ 2023-02-05 11:50 ` Floris van Manen via ntg-context
2023-02-05 12:13 ` Hans Hagen via ntg-context
1 sibling, 0 replies; 8+ messages in thread
From: Floris van Manen via ntg-context @ 2023-02-05 11:50 UTC (permalink / raw)
To: ntg-context; +Cc: Floris van Manen
On 05/02/2023 12:32, Pablo Rodriguez via ntg-context wrote:
> Are we missing something or is this a bug?
If you add a \tt at the beginning, the lines have different length.
not sure why, but there is a reason to it...
\startTEXpage[offset=3em]
\tt
\setupalign[tolerant,stretch]
\dorecurse {10} {%
some sha
\sha{8b2f3c087046c3943ace0dc4f958ef2138e58a51b40e%
ef6fab6fa1aeb845cc257a410ab1b914bc399b4293f%
31c76fc2c73e5be5ea4d329f9e6820984688efec2} and
}
\stopTEXpage
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-05 11:32 ` Pablo Rodriguez via ntg-context
2023-02-05 11:50 ` Floris van Manen via ntg-context
@ 2023-02-05 12:13 ` Hans Hagen via ntg-context
2023-02-05 15:52 ` Pablo Rodriguez via ntg-context
1 sibling, 1 reply; 8+ messages in thread
From: Hans Hagen via ntg-context @ 2023-02-05 12:13 UTC (permalink / raw)
To: Pablo Rodriguez via ntg-context; +Cc: Hans Hagen
On 2/5/2023 12:32 PM, Pablo Rodriguez via ntg-context wrote:
> On 2/4/23 10:37, Pablo Rodriguez via ntg-context wrote:
>> On 2/4/23 07:49, Hugo Landau via ntg-context wrote:
>>> On this page of the wiki there is an example for wrapping long words,
>>> like long hexadecimal strings:
>>>
>>> https://wiki.contextgarden.net/Wrapping
>>>
>>> This example is buggy because it deletes one character at the point that
>>> it is wrapped.
>>>
>>> Anyone have a solution?
>>
>> Many thanks for your report, Hugo.
>>
>> I use this code from time to time and I totally overlooked this.
>>
>> Have you checked all options that the sample contains?
>
> Hans,
>
> I have just checked that these line breakings loose a character in all
> options.
>
> The next sample displays the issue clearly:
>
>
> \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}
>
> \starttext
> \hyphenatedword{\sha{8b2f3c087046c3943ace0dc4f958ef2138e58a51b40e%
> ef6fab6fa1aeb845cc257a410ab1b914bc399b4293f%
> 31c76fc2c73e5be5ea4d329f9e6820984688efec2}}
> \stoptext
>
> Are we missing something or is this a bug?
what do you expect as result? (maybe try \righthyphenmin=1)
-----------------------------------------------------------------
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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-05 12:13 ` Hans Hagen via ntg-context
@ 2023-02-05 15:52 ` Pablo Rodriguez via ntg-context
2023-02-06 17:59 ` Hans Hagen via ntg-context
0 siblings, 1 reply; 8+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-02-05 15:52 UTC (permalink / raw)
To: Hans Hagen via ntg-context; +Cc: Pablo Rodriguez
On 2/5/23 13:13, Hans Hagen via ntg-context wrote:
> On 2/5/2023 12:32 PM, Pablo Rodriguez via ntg-context wrote:
>> [...]
>> Are we missing something or is this a bug?
> what do you expect as result? (maybe try \righthyphenmin=1)
Line breaks are removing characters.
In the sample below, output from
\hsize\zeropoint
\sha{a1b2c3d4}
reads:
a
_
_
_
_
3d4
I’m afraid \righthyphenmin=-1 prevents hyphenation (it seems to do it
everywhere).
Sorry, but I don’t get what is wrong here.
Many thanks for your help,
Pablo
\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]
\unexpanded\def\sha#1%
{\begingroup\tt
\righthyphenmin=-1
\sethyphenationfeatures[sha]%
\setuphyphenation[method=traditional]%
#1%
\endgroup}
\starttext
\startTEXpage[width=6em, offset=.25em]
\hsize\zeropoint
\sha{a1b2c3d4}
extraordinary linguistics
\righthyphenmin=-1
extraordinary linguistics
\stopTEXpage
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-05 15:52 ` Pablo Rodriguez via ntg-context
@ 2023-02-06 17:59 ` Hans Hagen via ntg-context
0 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen via ntg-context @ 2023-02-06 17:59 UTC (permalink / raw)
To: Pablo Rodriguez via ntg-context; +Cc: Hans Hagen
On 2/5/2023 4:52 PM, Pablo Rodriguez via ntg-context wrote:
> On 2/5/23 13:13, Hans Hagen via ntg-context wrote:
>> On 2/5/2023 12:32 PM, Pablo Rodriguez via ntg-context wrote:
>>> [...]
>>> Are we missing something or is this a bug?
>> what do you expect as result? (maybe try \righthyphenmin=1)
>
> Line breaks are removing characters.
>
> In the sample below, output from
>
> \hsize\zeropoint
> \sha{a1b2c3d4}
>
> reads:
>
> a
> _
> _
> _
> _
> 3d4
>
> I’m afraid \righthyphenmin=-1 prevents hyphenation (it seems to do it
> everywhere).
This
\unexpanded\def\sha#1%
{\begingroup
\sethyphenationfeatures[sha]%
\showglyphs
\righthyphenmin1
#1%
\endgroup}
gives
a·
·
·
·
·
·
4
-----------------------------------------------------------------
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 / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Bug in verbatim wrapping examples on wiki
2023-02-04 6:49 Bug in verbatim wrapping examples on wiki Hugo Landau via ntg-context
2023-02-04 9:37 ` Pablo Rodriguez via ntg-context
@ 2023-02-15 18:35 ` Pablo Rodriguez via ntg-context
1 sibling, 0 replies; 8+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2023-02-15 18:35 UTC (permalink / raw)
To: Hugo Landau via ntg-context; +Cc: Pablo Rodriguez
On 2/4/23 07:49, Hugo Landau via ntg-context wrote:
> On this page of the wiki there is an example for wrapping long words,
> like long hexadecimal strings:
>
> https://wiki.contextgarden.net/Wrapping
>
> This example is buggy because it deletes one character at the point that
> it is wrapped.
Hugo,
I have just updated the wiki with another way of line breaking SHA sums:
https://wiki.contextgarden.net/Wrapping#Line_breaking_with_SHA512_sums
It avoids the issue you encountered and it is an easy workaround.
Just in case it might help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-02-15 18:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-04 6:49 Bug in verbatim wrapping examples on wiki Hugo Landau via ntg-context
2023-02-04 9:37 ` Pablo Rodriguez via ntg-context
2023-02-05 11:32 ` Pablo Rodriguez via ntg-context
2023-02-05 11:50 ` Floris van Manen via ntg-context
2023-02-05 12:13 ` Hans Hagen via ntg-context
2023-02-05 15:52 ` Pablo Rodriguez via ntg-context
2023-02-06 17:59 ` Hans Hagen via ntg-context
2023-02-15 18:35 ` Pablo Rodriguez via ntg-context
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).