On the off chance that someone else may be interested, here is a lua filter that works by combining your walk_block filter with the one mentioned in this forum by EBkysko (link) . As written above, your filter can work for a single string, e.g. the surname, because in the AST the initials and in-between space are separate strings. The modified version below gets the surname and initials (Smith, J.) underlined in the references: ``````lua local underline_author_filter = { Para = function(el) if el.t == "Para" then for k,_ in ipairs(el.content) do if el.content[k].t == "Str" and el.content[k].text == "Smith," and el.content[k+1].t == "Space" and el.content[k+2].t == "Str" and el.content[k+2].text:find("^J.") then local _,e = el.content[k+2].text:find("^J.") local rest = el.content[k+2].text:sub(e+1) el.content[k] = pandoc.Underline { pandoc.Str("Smith, J.") } el.content[k+1] = pandoc.Str(rest) table.remove(el.content, k+2) end end end return el end } function Div (div) if 'refs' == div.identifier then return pandoc.walk_block(div, underline_author_filter) end return nil end `````` On Monday, 23 November 2020 at 21:37:37 UTC+2 BP wrote: > To traverse only the contents of a specific div in a Lua filter you want > to use the pandoc.walk_block function, something like this: > > ``````lua > local underline_author_filter = { > Str = function (str) > if 'A. U. Thor' == str.text then > return pandoc.Underline(str) > end > return nil > end > } > > function Div (div) > if 'refs' == div.identifier then > return pandoc.walk_block(div, underline_author_filter) > end > return nil > end > `````` > > -- > Better --help|less than helpless > > Den mån 23 nov. 2020 16:39gnpan skrev: > >> Thanks for the quick reply. I ended up creating a .json file, then a >> global find & replace in that, and then converted it to pdf. Works fine. I >> also had a go with a simple lua filter, but it only worked for strings in >> the body text, not the bibliography - not sure how to make it work for the >> bibliography div. >> >> On Sunday, 22 November 2020 at 23:21:49 UTC+2 John MacFarlane wrote: >> >>> >>> The citeproc library doesn't allow any formatting in given names, >>> so this bit of formatting is lost. >>> >>> I'm not too tempted to change this. For things like >>> initialization, it's very convenient to have plain strings >>> here. >>> >>> I would suggest using a lua filter which operates on the >>> bibliography Div and runs after the citeproc phase. >>> It can just find Str elements with your name and put >>> them in an Underline. >>> >>> >>> gnpan writes: >>> >>> > In versions previous to 2.11 (latest was 2.10.1) I could highlight >>> only my >>> > name in reference lists (e.g. for cv) using the trick shown here >>> > >>> https://tex.stackexchange.com/questions/18664/underline-my-name-in-the-bibliography, >>> >>> > which involves modifying my name in the .bib file and adding a >>> \newcommand >>> > under header-includes in the .txt file (see files below for MWE). This >>> does >>> > not work in subsequent pandoc versions and I assume it is an issue of >>> > citeproc vs. pandoc-citeproc. >>> > >>> > MWE (note that the default templates that came with each version have >>> to be >>> > used to avoid cslreference errors): >>> > For v.2.11.2: >>> > pandoc --pdf-engine=xelatex --citeproc --bibliography=test.bib >>> > --csl=nature.csl -o test11.pdf test.txt >>> > >>> > For v.2.10.1: >>> > pandoc --pdf-engine=xelatex --bibliography=test.bib --csl=nature.csl >>> -o >>> > test10.pdf test.txt >>> > Files: >>> > 1. test.txt contents: >>> > --- >>> > header-includes: >>> > - \newcommand{\myname}[1]{\textbf{First, A.}} >>> > --- >>> > >>> > Test [@first_test_2020] >>> > >>> > 2. test.bib file contents: >>> > @Article{first_test_2020, >>> > title = {Test title}, >>> > journaltitle = {Journal}, >>> > author = {{\myname{first}} and Second, B. and Third, C.}, >>> > date = {2020} >>> > } >>> > >>> > 3. nature.csl: https://www.zotero.org/styles?q=nature >>> > 4. Result with 2.10: test10.pdf >>> > >>> > 5. Result with 2.11: test11.pdf >>> > >>> > >>> > Sorry for cross-posting this from the github site (#6856), not sure >>> which >>> > is more appropriate. >>> > Thanks >>> > George >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> Groups "pandoc-discuss" group. >>> > To unsubscribe from this group and stop receiving emails from it, send >>> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> > To view this discussion on the web visit >>> https://groups.google.com/d/msgid/pandoc-discuss/ce795365-1926-49ca-947d-2dac0fa75f43n%40googlegroups.com. >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/pandoc-discuss/7aab780f-2a4e-4641-bc69-adc88280730an%40googlegroups.com >> >> . >> > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8363308b-95a5-42c1-bfad-6cc12949df35n%40googlegroups.com.