[NTG-context] Modifying bibliography entries using lua

Hans Hagen j.hagen at xs4all.nl
Mon Jul 23 23:32:03 CEST 2018


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
-----------------------------------------------------------------


More information about the ntg-context mailing list