public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Cannot create custom author highlight in reference list - works in v.2.10.1
@ 2020-11-22 14:06 gnpan
       [not found] ` <ce795365-1926-49ca-947d-2dac0fa75f43n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: gnpan @ 2020-11-22 14:06 UTC (permalink / raw)
  To: pandoc-discuss


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



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 
<https://github.com/jgm/pandoc/files/5559278/test10.pdf>
5. Result with 2.11: test11.pdf 
<https://github.com/jgm/pandoc/files/5559279/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-discuss+unsubscribe-/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.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found] ` <ce795365-1926-49ca-947d-2dac0fa75f43n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-11-22 21:21   ` John MacFarlane
       [not found]     ` <m2lfetdr4y.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2020-11-22 21:21 UTC (permalink / raw)
  To: gnpan, pandoc-discuss


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 <g.panayotou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
> <https://github.com/jgm/pandoc/files/5559278/test10.pdf>
> 5. Result with 2.11: test11.pdf 
> <https://github.com/jgm/pandoc/files/5559279/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-discuss+unsubscribe-/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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found]     ` <m2lfetdr4y.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-11-23 15:39       ` gnpan
       [not found]         ` <7aab780f-2a4e-4641-bc69-adc88280730an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2021-01-06 18:48       ` amph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  1 sibling, 1 reply; 8+ messages in thread
From: gnpan @ 2020-11-23 15:39 UTC (permalink / raw)
  To: pandoc-discuss


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

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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
> > <https://github.com/jgm/pandoc/files/5559278/test10.pdf>
> > 5. Result with 2.11: test11.pdf 
> > <https://github.com/jgm/pandoc/files/5559279/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-discuss+unsubscribe-/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.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found]         ` <7aab780f-2a4e-4641-bc69-adc88280730an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-11-23 19:37           ` BPJ
       [not found]             ` <CADAJKhBE6p41ke4qFiABjQanSXzFMMfi=OmwCKaYa7fw=FtcFA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: BPJ @ 2020-11-23 19:37 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 4750 bytes --]

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 <g.panayotou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
>> > <https://github.com/jgm/pandoc/files/5559278/test10.pdf>
>> > 5. Result with 2.11: test11.pdf
>> > <https://github.com/jgm/pandoc/files/5559279/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-discuss+unsubscribe-/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
> <https://groups.google.com/d/msgid/pandoc-discuss/7aab780f-2a4e-4641-bc69-adc88280730an%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADAJKhBE6p41ke4qFiABjQanSXzFMMfi%3DOmwCKaYa7fw%3DFtcFA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 7037 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found]             ` <CADAJKhBE6p41ke4qFiABjQanSXzFMMfi=OmwCKaYa7fw=FtcFA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2021-01-06 16:44               ` gnpan
  2021-02-04 17:39               ` gnpan
  1 sibling, 0 replies; 8+ messages in thread
From: gnpan @ 2021-01-06 16:44 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks BP, I did try but my limited grasp of lua filters didn't get me far, 
so I ended up doing a find and replace of the relevant text strings in an 
intermediate json file and then created a pdf from that - a few extra steps 
but it works fine and it's not something I have to do very often - who 
wants to see my CV at my age anyway... 
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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
>>> > <https://github.com/jgm/pandoc/files/5559278/test10.pdf> 
>>> > 5. Result with 2.11: test11.pdf 
>>> > <https://github.com/jgm/pandoc/files/5559279/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 
>> <https://groups.google.com/d/msgid/pandoc-discuss/7aab780f-2a4e-4641-bc69-adc88280730an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/ee858c75-c67b-48f6-ba50-500098ae9262n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found]     ` <m2lfetdr4y.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  2020-11-23 15:39       ` gnpan
@ 2021-01-06 18:48       ` amph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]         ` <2b0ecfee-5114-4808-967d-e25efc01577fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: amph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2021-01-06 18:48 UTC (permalink / raw)
  To: pandoc-discuss


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

While I appreciate that accepting formatting of the type requested might be 
problematical, I am reminded of "Falsehoods Programmers Believe About Names 
<https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/>" 
by Patrick McKenzie.

-- 
Rik
On Sunday, November 22, 2020 at 4:21:49 PM UTC-5 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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
> > <https://github.com/jgm/pandoc/files/5559278/test10.pdf>
> > 5. Result with 2.11: test11.pdf 
> > <https://github.com/jgm/pandoc/files/5559279/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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/2b0ecfee-5114-4808-967d-e25efc01577fn%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found]         ` <2b0ecfee-5114-4808-967d-e25efc01577fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2021-01-06 20:30           ` BPJ
  0 siblings, 0 replies; 8+ messages in thread
From: BPJ @ 2021-01-06 20:30 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 4729 bytes --]

Some systems can't handle something as simple as my official given name
which is double, with space between the parts rather than a hyphen. I get
an error because of the space or they just chop off the second half.
Sometimes the system, or people, insert a hyphen in place of the space, or
worse a hyphen between the second half and my surname.

True enough you should make no assumptions about names, neither of people,
places or anything else. Nor about the relative order of zip codes and
place names or house numbers and street names for that matter.

-- 
Better --help|less than helpless

Den ons 6 jan. 2021 19:48amph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <amphiboly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> While I appreciate that accepting formatting of the type requested might
> be problematical, I am reminded of "Falsehoods Programmers Believe About
> Names
> <https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/>"
> by Patrick McKenzie.
>
> --
> Rik
> On Sunday, November 22, 2020 at 4:21:49 PM UTC-5 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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
>> > <https://github.com/jgm/pandoc/files/5559278/test10.pdf>
>> > 5. Result with 2.11: test11.pdf
>> > <https://github.com/jgm/pandoc/files/5559279/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-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/2b0ecfee-5114-4808-967d-e25efc01577fn%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/2b0ecfee-5114-4808-967d-e25efc01577fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CADAJKhBKCv082-eg3%2Bc%3D8KF7Uc70mU6vh7wV7nwkQtFfH7DGhQ%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 6927 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Cannot create custom author highlight in reference list - works in v.2.10.1
       [not found]             ` <CADAJKhBE6p41ke4qFiABjQanSXzFMMfi=OmwCKaYa7fw=FtcFA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2021-01-06 16:44               ` gnpan
@ 2021-02-04 17:39               ` gnpan
  1 sibling, 0 replies; 8+ messages in thread
From: gnpan @ 2021-02-04 17:39 UTC (permalink / raw)
  To: pandoc-discuss


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

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) 
<https://groups.google.com/g/pandoc-discuss/c/RyX2czqyZ10/m/EltdkHShAwAJ>. 
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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 <g.pan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 
>>> > <https://github.com/jgm/pandoc/files/5559278/test10.pdf> 
>>> > 5. Result with 2.11: test11.pdf 
>>> > <https://github.com/jgm/pandoc/files/5559279/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 
>> <https://groups.google.com/d/msgid/pandoc-discuss/7aab780f-2a4e-4641-bc69-adc88280730an%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-02-04 17:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 14:06 Cannot create custom author highlight in reference list - works in v.2.10.1 gnpan
     [not found] ` <ce795365-1926-49ca-947d-2dac0fa75f43n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-11-22 21:21   ` John MacFarlane
     [not found]     ` <m2lfetdr4y.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-11-23 15:39       ` gnpan
     [not found]         ` <7aab780f-2a4e-4641-bc69-adc88280730an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-11-23 19:37           ` BPJ
     [not found]             ` <CADAJKhBE6p41ke4qFiABjQanSXzFMMfi=OmwCKaYa7fw=FtcFA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-01-06 16:44               ` gnpan
2021-02-04 17:39               ` gnpan
2021-01-06 18:48       ` amph...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]         ` <2b0ecfee-5114-4808-967d-e25efc01577fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-01-06 20:30           ` BPJ

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