ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: alephzorro <alephzorro@protonmail.com>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Accessing raw titles in textcommand in TOC
Date: Fri, 21 Feb 2020 15:04:16 +0100	[thread overview]
Message-ID: <4f4979db-c7b5-3ef0-6ae1-d56d77e5f399@xs4all.nl> (raw)
In-Reply-To: <MWS-wUYUSasQH9YXCGogQaPlHqYS6M5j9lgRQYr-O5qJEyCmZvlBmcOFBeApKaY6hqDjDxWK59kDAe1XXLjDMOurtoFO-542zhz0HcHhRec=@protonmail.com>

On 2/21/2020 2:34 PM, alephzorro wrote:
> Hello,
> 
> I would like to display titles differently in TOC than they appear in 
> text. For example, MyChapter1 -> 1retpahCyM. Basically any highly 
> non-trivial transformation that really needs Lua.

\starttext

     \completecontent

     \startchapter[title={Sample Chapter},list={retpahC elpmaS}]
     \stopchapter

\stoptext


> I've written simple Lua macros before, but the following approach trying 
> to define textcommand does not work since I can't find the way to pass 
> the raw title to my transform function.
> 
> 
> 
> 
> \startluacode
> userdata = userdata or {}
> function userdata.mytransform(title)
>      --context(title) --this is just fine, but isn't very useful
>      context(string.reverse(title))
> end
> \stopluacode
> 
> \def\transformtitle#1%
>      {\ctxlua{userdata.mytransform([==[#1]==])}}
> 
> \setuplist[chapter][textcommand=\transformtitle]
> 
> 
> \starttext
> \completecontent
> 
> \startchapter[title={Sample Chapter}]
> \stopchapter
> \stoptext
> 
> 
> When I print the actual title that is passed to mytransform, all I get 
> is \currentlistentrytitle and I haven't succeed expanding it (and 
> there's all kind of formatting stuff and so on going on I suppose). 
> Sections have "deeptextcommand" which is somewhat what I'm after here, 
> but I've not found similar option for TOC. So, is there a way to get 
> just the raw titles?
> 
> Jason C.
> 
> 
> 
> 
> 
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2020-02-21 14:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 13:34 alephzorro
2020-02-21 14:04 ` Hans Hagen [this message]
2020-02-22  5:57   ` alephzorro
2020-02-21 18:42 ` Wolfgang Schuster
2020-02-22  6:03   ` alephzorro

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=4f4979db-c7b5-3ef0-6ae1-d56d77e5f399@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=alephzorro@protonmail.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).