Re: [NTG-context] Hyphentation/Linebreak after x characters

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

Benjamin Buchmuller schrieb am 23.04.2020 um 23:16:
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

On 4/23/2020 17:50, Wolfgang Schuster wrote:
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

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
participants (3)
-
Benjamin Buchmuller
-
Rik Kabel
-
Wolfgang Schuster