ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: luigi scarso <luigi.scarso@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: break strings
Date: Mon, 13 Jun 2011 15:59:40 +0200	[thread overview]
Message-ID: <BANLkTim1NFsf1SYwAtLWCBDTZKxqsY0yVg@mail.gmail.com> (raw)
In-Reply-To: <DB6DE1BB-95F5-4BD3-931A-473247FFC39F@st.estfiles.de>

On Mon, Jun 13, 2011 at 3:52 PM, Steffen Wolfrum <context@st.estfiles.de> wrote:

>> Where is the difference ?
>>
>> \starttext
>>
>>
>> \showframe
>>
>> \define[1]\ThisHelps {\handletokens#1\with{\hskip 0pt plus
>> .1pt\firstofoneargument}}
>>
>> Test text test text\ThisHelps
>> {9769387937933hhgiuiuziuziduzid93739837fhieuhifeuhfeiu39739837938398zfhfdkuhfiufhz398739837r98z379dihhfiu}
>>
>> \define[1]\ThisHelpsLuigi{%
>> \startluacode
>> s='#1'
>> s= string.gsub(s,'(.)',"\%1\\hskip0sp")
>> % maybe only some chars...
>> %s= string.gsub(s,'[=/]',"\%1\\hskip0sp")
>> context(s)
>> \stopluacode}
>>
>> Test text test text\ThisHelpsLuigi
>> {9769387937933hhgiuiuziuziduzid93739837fhieuhifeuhfeiu39739837938398zfhfdkuhfiufhz398739837r98z379dihhfiu}
>>
>> \stoptext
>
>
> Just my "greenness" with luacode ...
>
> I didn't expect that it could be wrapped so easily in an handy \define command:
> context(s) is wrapped in start/stopluacode is wrapped in \define[1]\LuigiHelps{...}
The key point is
 % maybe only some chars...
 %s= string.gsub(s,'[=/]',"\%1\\hskip0sp")
With '[=/]'
you define a set of chars (only '=' and '/' in this example)
so that only '=' => '=\hskip0sp'
and
'/' => '/\hskip0sp'
i.e. breaks appear only on '=' and '/'.
It' possible to define whatever char you want, but you must pay attention to '%'
'#' etc. (as you do with \catcode)

-- 
luigi
___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2011-06-13 13:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 12:12 Steffen Wolfrum
2011-06-13 12:19 ` luigi scarso
2011-06-13 13:07   ` Steffen Wolfrum
2011-06-13 12:25 ` Wolfgang Schuster
2011-06-13 13:18   ` Steffen Wolfrum
2011-06-13 13:40     ` luigi scarso
2011-06-13 13:52       ` Steffen Wolfrum
2011-06-13 13:59         ` luigi scarso [this message]
2011-06-13 13:58       ` Wolfgang Schuster
2011-06-13 14:02         ` luigi scarso
2011-06-13 20:19         ` Hans Hagen

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=BANLkTim1NFsf1SYwAtLWCBDTZKxqsY0yVg@mail.gmail.com \
    --to=luigi.scarso@gmail.com \
    --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).