[NTG-context] Modifying bibliography entries using lua

Stanislav Sokolenko stanislav at sokolenko.net
Mon Jul 23 18:42:16 CEST 2018


Dear list,

I'm struggling to output bibliography entries into lua for string 
modification (like making a particular author name bold). In effect, I 
just need something like the following:

\starttexdefinition btx:customauthor
     \startluacode
     local text = context.btxflush('author')
     -- tex.sprint(text) -- fails because text remains nil
     \stopluacode
\stoptexdefinition

It's clear that btxflux is the wrong function for this as it writes the 
contents to file rather than returning a variable in lua... Is there a 
way to directly access what btxflush is writing through the publications 
table or other means? I've gone over the source code but I can't 
decipher what btxflush is actually doing.

Thanks,

Stan

Longer MNWE:

\stopluacode

\startbuffer[ref]
@article{solo,
   author = {Lastname, Firstname},
   title = {Solo work},
   journal = {Journal},
   year = {2000},
   month = {1},
   volume = {1}
}
\stopbuffer

\usebtxdataset[ref][ref.buffer]
\setupbtx[dataset=ref]

\definebtxrendering[ref][dataset=ref]
\setupbtx[default:cite]
   [alternative=authoryear,
    etallimit=1]


\starttexdefinition btx:customauthor
     \startluacode
     local text = context.btxflush('author')
     -- tex.sprint(text) -- text remains nill
     \stopluacode
\stoptexdefinition

\startsetups btx:default:list:article
     \texdefinition{btx:customauthor}
     \texdefinition{btx:default:title}
     \texdefinition{btx:default:journal}
     \texdefinition{btx:default:year}
     \removeunwantedspaces
     \removepunctuation
     \btxperiod
\stopsetups

\starttext

Citations: \cite[solo]

\startsubject[title=Bibliography]
\placelistofpublications[ref][method=dataset]
\stopsection

\stoptext




More information about the ntg-context mailing list