From: Hans Hagen <j.hagen@xs4all.nl>
To: Stanislav Sokolenko <stanislav@sokolenko.net>,
mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Modifying bibliography entries using lua
Date: Mon, 23 Jul 2018 23:32:03 +0200 [thread overview]
Message-ID: <1a6a6c0b-f0cc-424e-2a54-1c6e262fcaa6@xs4all.nl> (raw)
In-Reply-To: <17cae65b-7970-0827-e90a-2a97be436f43@sokolenko.net>
On 7/23/2018 10:17 PM, Stanislav Sokolenko wrote:
> Thanks Hans, that's really helpful!
>
>> This is not for the fainthearted so here we go
>>
>> \startluacode
>> function document.MyBoldPub(set,tag)
>> -- local a = publications.getfield(set,tag,"author")
>> -- inspect(a)
>> -- local c = publications.getcasted(set,tag,"author")
>> -- inspect(c)
>> if c[1].surnames[1] == "Myname" then
>> context.bold(function()
>> context.btxflush('author')
>> end )
>> else
>> context.btxflush('author')
>> end
>> end
>> \stopluacode
>
> So if I wanted to bold one specific author in a reference of many, I can
> just loop over publications.getcasted(...), and print the appropriate
> names, initials, etc...
>
> That said -- is there any way to call the appropriate authorconversion
> routine based on the \setupbtx settings? I found the
> publications.authorhashers method table, which seems to do most of this
> work, but I'm not sure how to pick the appropriate method and ensure
> that the correct separators are used.
Best use the setups provided than reinvent the logic.
\startluacode
function document.CheckMeB(set,tag,aut)
local c = publications.getcasted(set,tag,"author")
if c[aut].surnames[1] == "Foo" then
context("\\bf")
end
end
\stopluacode
\startsetups btx:list:author:normalshort
\fastsetup{btx:list:author:concat}
\begingroup
\ctxluacode{document.CheckMeB("\currentbtxdataset","\currentbtxtag",\number\currentbtxauthorindex)}
\ifx\currentbtxinitials\empty \else
\currentbtxinitials
\btxparameter{separator:initials}
\fi
\ifx\currentbtxvons\empty \else
\currentbtxvons
\ifx\currentbtxsurnames\empty \else
\btxparameter{separator:vons}
\fi
\fi
\ifx\currentbtxsurnames\empty \else
\currentbtxsurnames
\ifx\currentbtxjuniors\empty \else
\btxparameter{separator:juniors}
\currentbtxjuniors
\fi
\fi
\endgroup
\fastsetup{btx:list:author:others}
\stopsetups
Or something similar (there are several wasy to do this).
Hans
-----------------------------------------------------------------
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
___________________________________________________________________________________
next prev parent reply other threads:[~2018-07-23 21:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 16:42 Stanislav Sokolenko
2018-07-23 18:40 ` Hans Hagen
2018-07-23 20:17 ` Stanislav Sokolenko
2018-07-23 21:32 ` Hans Hagen [this message]
2018-07-24 14:41 ` Stanislav Sokolenko
2018-07-24 16:29 ` 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=1a6a6c0b-f0cc-424e-2a54-1c6e262fcaa6@xs4all.nl \
--to=j.hagen@xs4all.nl \
--cc=ntg-context@ntg.nl \
--cc=stanislav@sokolenko.net \
/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).