ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Stanislav Sokolenko <stanislav@sokolenko.net>
To: Hans Hagen <j.hagen@xs4all.nl>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Modifying bibliography entries using lua
Date: Tue, 24 Jul 2018 11:41:10 -0300	[thread overview]
Message-ID: <943e8809-b5df-45ea-a7b1-3de5520e10e3@sokolenko.net> (raw)
In-Reply-To: <1a6a6c0b-f0cc-424e-2a54-1c6e262fcaa6@xs4all.nl>


[-- Attachment #1.1: Type: text/plain, Size: 3019 bytes --]

That's perfect, thank you!

On 2018-07-23 06:32 PM, Hans Hagen wrote:
> \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 

I went with the following little extension to match and make bold 
multiple names:

|\startbuffer[ref]@article{solo, author ={MyLast, MyFirst}, title ={Solo 
work}, journal ={Journal}, year ={2000}, month ={1}, volume 
={1}}@article{co, author ={OtherLast, OtherFirst and MyLast, MyFirst and 
CoLast, CoFirst}, title ={Joint work}, journal ={Journal}, month ={1}, 
year ={2000}, volume 
={1}}\stopbuffer\usebtxdataset[ref][ref.buffer]\setupbtx[dataset=ref]\definebtxrendering[ref][dataset=ref]\setupbtx[default:cite][alternative=authoryear, 
etallimit=1, authorconversion=normalshort]\startluacodeBoldNames 
={{firstnames ="MyFirst", surnames ="MyLast"}, {initials ="C", surnames 
="CoLast"}, }function document.CompareNames(reference, targets)-- Loop 
over targets for _, target in pairs(targets)do -- Loop over fields for 
key, value in pairs(target)do if reference[key]==nil then break end 
full_entry ='' for _, part in ipairs(reference[key])do full_entry 
=full_entry .. ' ' .. part end full_entry =string.sub(full_entry, 2)if 
full_entry ==value then return(true)end end end return(false)end 
function document.BoldNames(set, tag, aut)local c 
=publications.getcasted(set, tag, "author")if 
document.CompareNames(c[aut], BoldNames)then context("\\bf")end end 
\stopluacode\startsetupsbtx:list:author:normalshort 
\fastsetup{btx:list:author:concat}\begingroup\ctxluacode{document.BoldNames("\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\starttextCitations: 
\cite[solo]\cite[co]\startsubject[title=Bibliography]\placelistofpublications[ref][method=dataset]\stopsection\stoptext|


Cheers,

Stan


[-- Attachment #1.2: Type: text/html, Size: 12807 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2018-07-24 14:41 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
2018-07-24 14:41       ` Stanislav Sokolenko [this message]
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=943e8809-b5df-45ea-a7b1-3de5520e10e3@sokolenko.net \
    --to=stanislav@sokolenko.net \
    --cc=j.hagen@xs4all.nl \
    --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).