ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henning Hraban Ramm <texml@fiee.net>
To: ntg-context@ntg.nl
Subject: [NTG-context] Re: get measures as dimension in Lua
Date: Mon, 10 Jun 2024 10:58:07 +0200	[thread overview]
Message-ID: <02784594-01af-408a-9824-7b4f68f71486@fiee.net> (raw)
In-Reply-To: <eaf0ff64-276c-47da-8524-413c5343237e@freedom.nl>

Thank you, Max, for the effort and Hans for a core solution!

Am 10.06.24 um 10:28 schrieb Hans Hagen via ntg-context:
> Indeed we can have:
> 
>      local namespace = tokens.getters.macro("??measure")
> 
>      function tex.getmeasure(name,asdimen)
>          local value = tex.getdimensionvalue(namespace..name)
>          if asdimen then
>              return value .. "sp"
>          else
>              return value
>          end
> 
> and when you want to avoid the namespace you can do:
> 
>      function tex.getmeasure(name,asdimen)
>          local value = 
> token.getexpansion("\\tointeger\\measured{"..name.."}")
>          if asdimen then
>              return value .. "sp"
>          else
>              return tonumber(value)
>          end
>      end
> 
> which is some 4 times slower. It'sindeed not documented (although there 
> are some examples in accessors-001.tex) but it's in one of my todo's 
> because I can use it in some places (there ar emopre such todo's) after 
> which it will be discussed in one of the lowlelvel manuals
> 
> i'll add tex.getmeasure to the core (but a bit different)

Not to be misunderstood, I couldn’t check yet, maybe I wasn’t clear:

I need to process the measure as a dimension, like \measured{Bleed}.

As far as I tried, neither tex.measured nor context.measured worked (but 
I wouldn’t swear on it, maybe I had a different error).

Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2024-06-10  8:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-09 20:12 [NTG-context] " Henning Hraban Ramm
2024-06-10  5:08 ` [NTG-context] " Max Chernoff
2024-06-10  8:28   ` Hans Hagen via ntg-context
2024-06-10  8:58     ` Henning Hraban Ramm [this message]
2024-06-13 17:24       ` Henning Hraban Ramm
2024-06-13 21:03         ` Hans Hagen via ntg-context

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=02784594-01af-408a-9824-7b4f68f71486@fiee.net \
    --to=texml@fiee.net \
    --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).