From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: luatex feature question/request
Date: Fri, 4 Apr 2008 15:48:24 -0400 (EDT) [thread overview]
Message-ID: <alpine.DEB.1.00.0804041546590.11038@nqv-yncgbc> (raw)
In-Reply-To: <20080404192659.GA5994@gaston.couberia.bzh>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1622 bytes --]
On Fri, 4 Apr 2008, Peter Münster wrote:
> On Fri, Apr 04 2008, Taco Hoekwater wrote:
>>
>> % engine=luatex
>>
>> \startluacode
>> function add_ties (line) return line:gsub(' ','~') end
>> \stopluacode
>>
>> \def\startfiltered
>> {\ctxlua {callback.register('process_input_buffer', add_ties)}}
>> \def\stopfiltered
>> {\ctxlua {callback.register('process_input_buffer', nil)}}
>>
>> \starttext
>> \startfiltered
>> Thus, I came to the conclusion that the designer of a new system
>> must not only be the implementer and first large||scale user; the
>> designer should also write the first user manual.
>> \stopfiltered
>> \stoptext
>>
>> Notice how it breaks only at hyphens? If you think that is because
>> those are the only valid breakpoints, you are actually slightly wrong:
>> there are still 'normal' spaces between 'system' and 'must' and between
>> 'the' and 'designer' (because EOL is converted to a space *after*
>> reading in the line buffer).
>>
>> The lua function is _much_ too simple. It will happily convert '\ '
>> into '\~', $a = 2~$ into $a~=~2~$, and "\TEX is" into "\TEX~is".
>
> Hello,
>
> Perhaps this one could be already useable for the OP:
>
> function add_ties(line)
> line = line:gsub('( %a) ', '%1~')
> line = line:gsub('^(%a) ', '%1~')
> line = line:gsub('( %a)$', '%1~%%')
> return line
> end
>
> Not working: $a = b + c$.
How about substituting with a macro \nonbreakbablespace (instead of ~) and
redefining \nonbreakablespace to \relax using \everymathematics or
\mathortext?
Aditya
[-- Attachment #2: Type: text/plain, Size: 487 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://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2008-04-04 19:48 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-04 5:09 Marcin Borkowski
2008-04-04 7:50 ` Hans Hagen
2008-04-04 8:33 ` Taco Hoekwater
2008-04-04 8:38 ` luigi scarso
2008-04-04 8:52 ` Taco Hoekwater
2008-04-04 8:58 ` Olivier Guéry
2008-04-04 9:08 ` Hans Hagen
2008-04-04 11:02 ` Olivier Guéry
2008-04-04 11:15 ` Wolfgang Schuster
2008-04-04 12:26 ` Olivier Guéry
2008-04-04 12:55 ` Peter Münster
2008-04-04 13:15 ` Olivier Guéry
2008-04-04 15:15 ` Peter Münster
2008-04-04 20:23 ` Olivier Guéry
2008-04-04 12:26 ` Hans Hagen
2008-04-04 13:09 ` Olivier Guéry
2008-04-15 19:18 ` Hans Hagen
2008-04-15 19:54 ` Olivier Guéry
2008-04-16 0:40 ` Arthur Reutenauer
2008-04-16 8:50 ` Hans Hagen
2008-04-16 10:19 ` Olivier Guéry
2008-04-16 12:46 ` Peter Münster
2008-04-16 14:20 ` Hans Hagen
2008-04-04 10:16 ` Peter Münster
2008-04-04 9:19 ` luigi scarso
2008-04-04 19:26 ` Peter Münster
2008-04-04 19:48 ` Aditya Mahajan [this message]
2008-04-04 20:03 ` Peter Münster
2008-04-04 20:07 ` Hans Hagen
2008-04-04 20:20 ` Taco Hoekwater
2008-04-04 9:57 ` Marcin Borkowski
2008-07-04 10:54 Marcin Borkowski
2008-07-04 14:23 ` Idris Samawi Hamid ادريس سماوي حامد
2008-07-04 15:01 ` Olivier
2008-07-04 17:38 ` Idris Samawi Hamid ادريس سماوي حامد
2008-07-04 20:34 ` Hans Hagen
2008-07-04 20:39 ` 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=alpine.DEB.1.00.0804041546590.11038@nqv-yncgbc \
--to=adityam@umich.edu \
--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).