From: Sietse Brouwer <sbbrouwer@gmail.com>
To: Alan BRASLAU <alan.braslau@cea.fr>,
mailing list for ConTeXt users <ntg-context@ntg.nl>,
Hans Hagen <pragma@wxs.nl>
Subject: Re: m-graph.mkiv format bug
Date: Mon, 15 Oct 2012 13:03:40 +0200 [thread overview]
Message-ID: <CAF=dkzzxgp47XWX3Rx9ScOnHxxGW+-RtqyxnZz_M2fgaTcuTDQ@mail.gmail.com> (raw)
In-Reply-To: <20121015124503.389c821d@sole>
Alan wrote:
> Figured it out (and we don't want to strip a leading minus sign):
>
> local function strip(s)
> return "\\times10^{"..(s:gsub("%+*0*([1-9])","%1")).."}"
> end
Better to anchor the pattern to the start of the string with `^` (and
then the nonzerodigitmatching is no longer needed):
gsub("^%+*0*", "")
Otherwise, you'll get 805 --> 85.
--Sietse
On Mon, Oct 15, 2012 at 12:45 PM, Alan BRASLAU <alan.braslau@cea.fr> wrote:
> On Mon, 15 Oct 2012 12:27:27 +0200
> Alan BRASLAU <alan.braslau@cea.fr> wrote:
>
>> On Mon, 15 Oct 2012 12:08:30 +0200
>> Sietse Brouwer <sbbrouwer@gmail.com> wrote:
>>
>> > > There is a bug with format() as redefined in m-graph.mkiv
>> > > 1e10 and 1e-10 truncate the tailing 0.
>> >
>> > The function strip() is removing 0 throughout the exponent, and I
>> > don't know what purpose that might serve. If we never want to remove
>> > zeroes, this works:
>> >
>> > local function strip(s)
>> > - return "\\times10^{"..(s:gsub("%+*0*","")).."}"
>> > + return "\\times10^{"..(s:gsub("%+*","")).."}"
>> > end
>> >
>> > Note that if the exponent is zero the "× 10^0" will be left out
>> > completely, in both the old and the new strip() function. This seems
>> > to be by design. Illustration of this behaviour:
>> >
>> > \usemodule[graph]
>> > \starttext
>> > \startMPpage
>> > label(format("@g","1e+0"),(2cm,-1cm)) ;
>> > \stopMPpage
>> > \stoptext
>>
>>
>> Thanks, this "fixes" it for now,
>> but I believe that the strip is intended to remove leading zeros, as
>> in label(format("@g","1e+08"),(2cm,-1cm)) ;
>>
>> I suppose that the correct syntax must be something like the regex
>> s/[+-]*0*\([1-9]\)/\1/
>> (not sure how to state this in lua gsub()...)
>
>
> Figured it out (and we don't want to strip a leading minus sign):
>
> local function strip(s)
> return "\\times10^{"..(s:gsub("%+*0*([1-9])","%1")).."}"
> end
>
>
> Alan
___________________________________________________________________________________
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
___________________________________________________________________________________
next prev parent reply other threads:[~2012-10-15 11:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-15 9:19 Alan BRASLAU
2012-10-15 10:08 ` Sietse Brouwer
2012-10-15 10:27 ` Alan BRASLAU
2012-10-15 10:45 ` Alan BRASLAU
2012-10-15 11:03 ` Sietse Brouwer [this message]
2012-10-15 12:21 ` Alan BRASLAU
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='CAF=dkzzxgp47XWX3Rx9ScOnHxxGW+-RtqyxnZz_M2fgaTcuTDQ@mail.gmail.com' \
--to=sbbrouwer@gmail.com \
--cc=alan.braslau@cea.fr \
--cc=ntg-context@ntg.nl \
--cc=pragma@wxs.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).