* Re: Hyphentation/Linebreak after x characters [not found] <mailman.281.1587672163.1194.ntg-context@ntg.nl> @ 2020-04-23 21:16 ` Benjamin Buchmuller 2020-04-23 21:50 ` Wolfgang Schuster 0 siblings, 1 reply; 5+ messages in thread From: Benjamin Buchmuller @ 2020-04-23 21:16 UTC (permalink / raw) To: ntg-context Hi Rik, Thanks for the fast reply! Your example works indeed nicely. However, within this solution my problem has shifted now (fully) towards breaking after the same number of characters, which seems to work for your sample string, but not for the sequences that I need to place. What I would like to achieve is something like: 5’-GATTGCTTACTCCTGGTTGG TGGGGCTTACATTCTGTCGCCTC AAAACTACTAGAGCCGGCATATT CTAGAAGGGCCGCCTTCATGTGG etc. (There might be hyphens or not, this is not so much important to me.) But what I get is currently: 5'-GATTGCTTACTCCTG- GTTGGTGGGGCTTACATTCT- GTCGCCTCAAAACTACTA- GAGCCGGCATATTCTA- GAAGGGCCGCCTTCATGTGGC- etc. Which looks ragged with \tt. Certainly, this is because ConTeXt applies the default hyphenation pattern. But I guess, there might be no “no language” pattern or is there? Also, I agree, it’s a bit odd that nright/nleft seem to make no difference towards the result. This is the MWE based on your solution: \define[2]\mycommandc{ \startxrow \startxcell o#1 \stopxcell \startxcell \tt\WORD{5'-#2} \stopxcell \stopxrow } \definebreakpoint[mybreaks][][nright=100,nleft=100,type=1] \setbreakpoints[mybreaks] \starttext \setupxtable[width=5cm] \startxtable \mycommandc{C}{GATTGCTTACTCCTGGTTGGTGGGGCTTACATTCTGTCGCCTCAAAACTACTAGAGCCGGCATATTCTAGAAGGGCCGCCTTCATGTGGCCTAGGGCACCATCGCGTACGAGGGCAAAAAATGAGTTTACCGCTGCGAAGTCTCTACGTCACGGCCAACCACAGTCCTGCTCCCAACGAAATTTAGACGCTGTCGTGAAACCTGAATTCGAGGATAAGCCGCGTCATGAAGAGTCTACTG} \stopxtable \stoptext > On 23 Apr 2020, at 22:02, ntg-context-request@ntg.nl wrote: > > Send ntg-context mailing list submissions to > ntg-context@ntg.nl > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.ntg.nl/mailman/listinfo/ntg-context > or, via email, send a message with subject or body 'help' to > ntg-context-request@ntg.nl > > You can reach the person managing the list at > ntg-context-owner@ntg.nl > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of ntg-context digest..." > Today's Topics: > > 1. Re: Hyphentation/Linebreak after x characters inside \WORD? > (Rik Kabel) > > From: Rik Kabel <ConTeXt@rik.users.panix.com> > Subject: Re: [NTG-context] Hyphentation/Linebreak after x characters inside \WORD? > Date: 23 April 2020 at 21:46:59 CEST > To: ntg-context@ntg.nl, benjamin.buchmuller@gmail.com > > > > > On 4/23/2020 15:01, Benjamin Buchmuller wrote: >> Sorry, I have just realized that the problem might not be \WORD{} actually, so this one hyphenates: >> >> \define[2]\mycommand{ >> \startxrow >> \startxcell o#1 \stopxcell >> \startxcell \tt\WORD #2 \stopxcell >> \stopxrow >> } >> >> Whereas these ones don’t: >> >> >> \define[2]\mycommand{ >> \startxrow >> \startxcell o#1 \stopxcell >> \startxcell \tt\WORD #2-3' \stopxcell >> \stopxrow >> } >> >> \define[2]\mycommand{ >> \startxrow >> \startxcell o#1 \stopxcell >> \startxcell 5'-\tt\WORD #2 \stopxcell >> \stopxrow >> } >> >> Assuming that this has to do with the presence of “-“ which will be the preferred breakpoint. So, I guess the questions boils down to how to define the second argument of >> >> \definebreakpoint[mybreaks][][nright=12,nleft=12,type=1] >> >> in this case or how to “deactivate” the default \setbreakpoints[compound]? >> >> >> >>> On 23 Apr 2020, at 20:46, Benjamin Buchmuller <benjamin.buchmuller@gmail.com> >>> wrote: >>> >>> Hi again, >>> >>> I am reading a CSV file into ConTeXt which contains long DNA sequences (>> 40 characters) to place in xtables. So far, this works fine. However, I need to uppercase the entries and need to \tt them. When I do this inside \WORD however, they don’t hyphenate any more. >>> >>> I’m using: >>> >>> \defineseparatedlist >>> [mylist] >>> [ >>> separator={,}, quotechar={"}, >>> command=\mycommand >>> ] >>> >>> \define[2]\mycommand{ >>> \startxrow >>> \startxcell o#1 \stopxcell >>> \startxcell 5’-{\tt\WORD{#2}}-3' \stopxcell >>> \stopxrow >>> } >>> >>> Since I don’t have access to each entry, I cant place hyphenation marks directly. Is there a way to tell ConTeXt to hyphenate after say, 12 characters? >>> >>> Thanks for your help. >>> >>> >>> Benjamin >>> > The following works for me: > > \define[2]\mycommanda{ > \startxrow > \startxcell o#1 \stopxcell > \startxcell \tt\WORD #2 \stopxcell > \stopxrow > } > > \define[2]\mycommandb{ > \startxrow > \startxcell o#1 \stopxcell > \startxcell \tt\WORD #2-3' \stopxcell > \stopxrow > } > > \define[2]\mycommandc{ > \startxrow > \startxcell o#1 \stopxcell > \startxcell 5'-\tt\WORD #2 \stopxcell > \stopxrow > } > > \definebreakpoint[mybreaks][][nright=12,nleft=12,type=1] > \setbreakpoints[mybreaks] > > \starttext > > \setupxtable[width=5cm] > \startxtablex > \mycommanda{A}{lsfkgjfkgshgkhigewhgajkdkfkalhfdklahfkhaakfakfh} > \mycommandb{B}{lsfkgjfkgshgkhigewhgajkdkfkalhfdklahfkhaakfakfh} > \mycommandc{C}{lsfkgjfkgshgkhigewhgajkdkfkalhfdklahfkhaakfakfh} > \stopxtable > > \stoptext > > > Producing: > > <nijiabomaaejpjhk.png> > > Indeed, it produces the same when nleft and nright are both set to 1 or 12 or 100, but not when setbreakpoints is removed. > > If you are trying to do something else, please provide an MWE. > > > ___________________________________________________________________________________ > 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://tex.aanhet.net > archive : https://foundry.supelec.fr/projects/contextrev/ > 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Hyphentation/Linebreak after x characters 2020-04-23 21:16 ` Hyphentation/Linebreak after x characters Benjamin Buchmuller @ 2020-04-23 21:50 ` Wolfgang Schuster 2020-04-23 22:03 ` Benjamin Buchmuller 2020-04-23 22:45 ` Rik Kabel 0 siblings, 2 replies; 5+ messages in thread From: Wolfgang Schuster @ 2020-04-23 21:50 UTC (permalink / raw) To: mailing list for ConTeXt users, Benjamin Buchmuller Benjamin Buchmuller schrieb am 23.04.2020 um 23:16: > Hi Rik, > > Thanks for the fast reply! Your example works indeed nicely. However, within this solution my problem has shifted now (fully) towards breaking after the same number of characters, which seems to work for your sample string, but not for the sequences that I need to place. > > What I would like to achieve is something like: > > 5’-GATTGCTTACTCCTGGTTGG > TGGGGCTTACATTCTGTCGCCTC > AAAACTACTAGAGCCGGCATATT > CTAGAAGGGCCGCCTTCATGTGG > etc. > > (There might be hyphens or not, this is not so much important to me.) > > But what I get is currently: > > 5'-GATTGCTTACTCCTG- > GTTGGTGGGGCTTACATTCT- > GTCGCCTCAAAACTACTA- > GAGCCGGCATATTCTA- > GAAGGGCCGCCTTCATGTGGC- > etc. > > Which looks ragged with \tt. Certainly, this is because ConTeXt applies the default hyphenation pattern. But I guess, there might be no “no language” pattern or is there? Also, I agree, it’s a bit odd that nright/nleft seem to make no difference towards the result. Hans posted a solution for a similar problem a few years ago [1] which can be adapted to your problem. \startluacode local shared = { start = 1, length = 1, before = nil, after = nil, left = false, right = false, } local all = table.setmetatableindex({ }, function(t,k) return shared end) languages.hyphenators.traditional.installmethod("dna", function(dictionary,word,n) return all end ) \stopluacode \definehyphenationfeatures [dna] [characters=all, alternative=dna] \starttext \startframedtext[width=6cm,style=mono] \sethyphenationfeatures[dna] \setuphyphenation[method=traditional] GATTGCTTACTCCTGGTTGG% TGGGGCTTACATTCTGTCGCCTC% AAAACTACTAGAGCCGGCATATT% CTAGAAGGGCCGCCTTCATGTGG% \stopframedtext \stoptext [1] https://mailman.ntg.nl/pipermail/ntg-context/2017/089106.html Wolfgang ___________________________________________________________________________________ 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] 5+ messages in thread
* Re: Hyphentation/Linebreak after x characters 2020-04-23 21:50 ` Wolfgang Schuster @ 2020-04-23 22:03 ` Benjamin Buchmuller 2020-04-23 22:45 ` Rik Kabel 1 sibling, 0 replies; 5+ messages in thread From: Benjamin Buchmuller @ 2020-04-23 22:03 UTC (permalink / raw) To: Wolfgang Schuster; +Cc: mailing list for ConTeXt users Thanks Wolfgang, this works perfectly. I will add this hint tomorrow to the Wiki. > On 23 Apr 2020, at 23:50, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote: > > Benjamin Buchmuller schrieb am 23.04.2020 um 23:16: >> Hi Rik, >> Thanks for the fast reply! Your example works indeed nicely. However, within this solution my problem has shifted now (fully) towards breaking after the same number of characters, which seems to work for your sample string, but not for the sequences that I need to place. >> What I would like to achieve is something like: >> 5’-GATTGCTTACTCCTGGTTGG >> TGGGGCTTACATTCTGTCGCCTC >> AAAACTACTAGAGCCGGCATATT >> CTAGAAGGGCCGCCTTCATGTGG >> etc. >> (There might be hyphens or not, this is not so much important to me.) >> But what I get is currently: >> 5'-GATTGCTTACTCCTG- >> GTTGGTGGGGCTTACATTCT- >> GTCGCCTCAAAACTACTA- >> GAGCCGGCATATTCTA- >> GAAGGGCCGCCTTCATGTGGC- >> etc. >> Which looks ragged with \tt. Certainly, this is because ConTeXt applies the default hyphenation pattern. But I guess, there might be no “no language” pattern or is there? Also, I agree, it’s a bit odd that nright/nleft seem to make no difference towards the result. > > Hans posted a solution for a similar problem a few years ago [1] > which can be adapted to your problem. > > \startluacode > > local shared = { > start = 1, > length = 1, > before = nil, > after = nil, > left = false, > right = false, > } > > local all = table.setmetatableindex({ }, function(t,k) > return shared > end) > > languages.hyphenators.traditional.installmethod("dna", > function(dictionary,word,n) > return all > end > ) > \stopluacode > > \definehyphenationfeatures > [dna] > [characters=all, > alternative=dna] > > \starttext > > \startframedtext[width=6cm,style=mono] > \sethyphenationfeatures[dna] > \setuphyphenation[method=traditional] > GATTGCTTACTCCTGGTTGG% > TGGGGCTTACATTCTGTCGCCTC% > AAAACTACTAGAGCCGGCATATT% > CTAGAAGGGCCGCCTTCATGTGG% > \stopframedtext > > \stoptext > > [1] https://mailman.ntg.nl/pipermail/ntg-context/2017/089106.html > > Wolfgang ___________________________________________________________________________________ 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] 5+ messages in thread
* Re: Hyphentation/Linebreak after x characters 2020-04-23 21:50 ` Wolfgang Schuster 2020-04-23 22:03 ` Benjamin Buchmuller @ 2020-04-23 22:45 ` Rik Kabel 2020-04-24 8:50 ` Benjamin Buchmuller 1 sibling, 1 reply; 5+ messages in thread From: Rik Kabel @ 2020-04-23 22:45 UTC (permalink / raw) To: ntg-context, Benjamin Buchmuller [-- Attachment #1.1: Type: text/plain, Size: 3000 bytes --] On 4/23/2020 17:50, Wolfgang Schuster wrote: > Benjamin Buchmuller schrieb am 23.04.2020 um 23:16: >> Hi Rik, >> >> Thanks for the fast reply! Your example works indeed nicely. However, >> within this solution my problem has shifted now (fully) towards >> breaking after the same number of characters, which seems to work for >> your sample string, but not for the sequences that I need to place. >> >> What I would like to achieve is something like: >> >> 5’-GATTGCTTACTCCTGGTTGG >> TGGGGCTTACATTCTGTCGCCTC >> AAAACTACTAGAGCCGGCATATT >> CTAGAAGGGCCGCCTTCATGTGG >> etc. >> >> (There might be hyphens or not, this is not so much important to me.) >> >> But what I get is currently: >> >> 5'-GATTGCTTACTCCTG- >> GTTGGTGGGGCTTACATTCT- >> GTCGCCTCAAAACTACTA- >> GAGCCGGCATATTCTA- >> GAAGGGCCGCCTTCATGTGGC- >> etc. >> >> Which looks ragged with \tt. Certainly, this is because ConTeXt >> applies the default hyphenation pattern. But I guess, there might be >> no “no language” pattern or is there? Also, I agree, it’s a bit odd >> that nright/nleft seem to make no difference towards the result. > > Hans posted a solution for a similar problem a few years ago [1] > which can be adapted to your problem. > > \startluacode > > local shared = { > start = 1, > length = 1, > before = nil, > after = nil, > left = false, > right = false, > } > > local all = table.setmetatableindex({ }, function(t,k) > return shared > end) > > languages.hyphenators.traditional.installmethod("dna", > function(dictionary,word,n) > return all > end > ) > \stopluacode > > \definehyphenationfeatures > [dna] > [characters=all, > alternative=dna] > > \starttext > > \startframedtext[width=6cm,style=mono] > \sethyphenationfeatures[dna] > \setuphyphenation[method=traditional] > GATTGCTTACTCCTGGTTGG% > TGGGGCTTACATTCTGTCGCCTC% > AAAACTACTAGAGCCGGCATATT% > CTAGAAGGGCCGCCTTCATGTGG% > \stopframedtext > > \stoptext > > [1] https://mailman.ntg.nl/pipermail/ntg-context/2017/089106.html > > Wolfgang > And without lua, just two lines of ConTeXt with a bit of TeX: \define[1]\DNA{\handletokens #1\with\DNAspacer} \define[1]\DNAspacer{#1\hskip 2.3pt plus .1pt} \define[2]\mycommandc{ \startxrow \startxcell o#1 \stopxcell \startxcell {\tt\WORD{\DNA{5'-#2}}}\stopxcell \stopxrow } \starttext \setupxtable[width=5cm] \startxtable \mycommandc{C}{gattgcttactcctggttggtggggcttacattctgtcgcctcaaaactactagagccggcatattctagaagggccgccttcatgtggcctagggcaccatcgcgtacgagggcaaaaaatgagtttaccgctgcgaagtctctacgtcacggccaaccacagtcctgctcccaacgaaatttagacgctgtcgtgaaacctgaattcgaggataagccgcgtcatgaagagtctactg} \stopxtable \stoptext Modify the skip as you see fit. -- Rik [-- Attachment #1.2: Type: text/html, Size: 5000 bytes --] [-- Attachment #2: Type: text/plain, Size: 493 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] 5+ messages in thread
* Re: Hyphentation/Linebreak after x characters 2020-04-23 22:45 ` Rik Kabel @ 2020-04-24 8:50 ` Benjamin Buchmuller 0 siblings, 0 replies; 5+ messages in thread From: Benjamin Buchmuller @ 2020-04-24 8:50 UTC (permalink / raw) To: Rik Kabel; +Cc: ntg-context Hi Rik, thank you as well, this works also nicely. I’ve created a wiki page meanwhile for wrapping text containing both solutions and the post on SHA keys. https://www.contextgarden.net/Wrapping Cheers Benjamin > On 24 Apr 2020, at 00:45, Rik Kabel <ConTeXt@rik.users.panix.com> wrote: > > > > On 4/23/2020 17:50, Wolfgang Schuster wrote: >> Benjamin Buchmuller schrieb am 23.04.2020 um 23:16: >>> Hi Rik, >>> >>> Thanks for the fast reply! Your example works indeed nicely. However, within this solution my problem has shifted now (fully) towards breaking after the same number of characters, which seems to work for your sample string, but not for the sequences that I need to place. >>> >>> What I would like to achieve is something like: >>> >>> 5’-GATTGCTTACTCCTGGTTGG >>> TGGGGCTTACATTCTGTCGCCTC >>> AAAACTACTAGAGCCGGCATATT >>> CTAGAAGGGCCGCCTTCATGTGG >>> etc. >>> >>> (There might be hyphens or not, this is not so much important to me.) >>> >>> But what I get is currently: >>> >>> 5'-GATTGCTTACTCCTG- >>> GTTGGTGGGGCTTACATTCT- >>> GTCGCCTCAAAACTACTA- >>> GAGCCGGCATATTCTA- >>> GAAGGGCCGCCTTCATGTGGC- >>> etc. >>> >>> Which looks ragged with \tt. Certainly, this is because ConTeXt applies the default hyphenation pattern. But I guess, there might be no “no language” pattern or is there? Also, I agree, it’s a bit odd that nright/nleft seem to make no difference towards the result. >> >> Hans posted a solution for a similar problem a few years ago [1] >> which can be adapted to your problem. >> >> \startluacode >> >> local shared = { >> start = 1, >> length = 1, >> before = nil, >> after = nil, >> left = false, >> right = false, >> } >> >> local all = table.setmetatableindex({ }, function(t,k) >> return shared >> end) >> >> languages.hyphenators.traditional.installmethod("dna", >> function(dictionary,word,n) >> return all >> end >> ) >> \stopluacode >> >> \definehyphenationfeatures >> [dna] >> [characters=all, >> alternative=dna] >> >> \starttext >> >> \startframedtext[width=6cm,style=mono] >> \sethyphenationfeatures[dna] >> \setuphyphenation[method=traditional] >> GATTGCTTACTCCTGGTTGG% >> TGGGGCTTACATTCTGTCGCCTC% >> AAAACTACTAGAGCCGGCATATT% >> CTAGAAGGGCCGCCTTCATGTGG% >> \stopframedtext >> >> \stoptext >> >> [1] https://mailman.ntg.nl/pipermail/ntg-context/2017/089106.html >> >> Wolfgang >> > And without lua, just two lines of ConTeXt with a bit of TeX: > > \define[1]\DNA{\handletokens #1\with\DNAspacer} > \define[1]\DNAspacer{#1\hskip 2.3pt plus .1pt} > \define[2]\mycommandc{ > \startxrow > \startxcell o#1 \stopxcell > \startxcell {\tt\WORD{\DNA{5'-#2}}}\stopxcell > \stopxrow > } > \starttext > \setupxtable[width=5cm] > \startxtable > \mycommandc{C}{gattgcttactcctggttggtggggcttacattctgtcgcctcaaaactactagagccggcatattctagaagggccgccttcatgtggcctagggcaccatcgcgtacgagggcaaaaaatgagtttaccgctgcgaagtctctacgtcacggccaaccacagtcctgctcccaacgaaatttagacgctgtcgtgaaacctgaattcgaggataagccgcgtcatgaagagtctactg} > \stopxtable > \stoptext > > Modify the skip as you see fit. > > -- > Rik > ___________________________________________________________________________________ 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] 5+ messages in thread
end of thread, other threads:[~2020-04-24 8:50 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <mailman.281.1587672163.1194.ntg-context@ntg.nl> 2020-04-23 21:16 ` Hyphentation/Linebreak after x characters Benjamin Buchmuller 2020-04-23 21:50 ` Wolfgang Schuster 2020-04-23 22:03 ` Benjamin Buchmuller 2020-04-23 22:45 ` Rik Kabel 2020-04-24 8:50 ` Benjamin Buchmuller
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).