ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Joey McCollum via ntg-context <ntg-context@ntg.nl>
To: Hans Hagen <j.hagen@xs4all.nl>,
	mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Joey McCollum <jmccollum20140511@gmail.com>
Subject: Re: Implementing a custom authorconversion for bibliographies
Date: Wed, 15 Sep 2021 13:01:35 -0400	[thread overview]
Message-ID: <CAGxRUG-2KcTb+wX1e8CEbgw2ZD8AJC3oa4ZWVZj2gxGipGFdBA@mail.gmail.com> (raw)
In-Reply-To: <CAGxRUG_kB8DKWRyRuU3vQXfOW0BW9ep3mussLkuRM-B48twg=w@mail.gmail.com>


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

Looks like it was just a small oversight on my part; I had to make sure I
added a corresponding \s!btx:\s!list:\s!author:invertedfirst setup for list
entries. Here's what finally works:

```
\startsetups \s!btx:\s!cite:\s!author:invertedfirst
    \ifnum\currentbtxauthorindex>\plusone
        \fastsetup{\s!btx:\s!cite:\s!author:normal}
    \else
        \fastsetup{\s!btx:\s!cite:\s!author:inverted}
    \fi
\stopsetups

...

\startsetups \s!btx:\s!list:\s!author:invertedfirst
    \ifnum\currentbtxauthorindex>\plusone
        \fastsetup{\s!btx:\s!list:\s!author:normal}
    \else
        \fastsetup{\s!btx:\s!list:\s!author:inverted}
    \fi
\stopsetups
```

Thanks again, Hans!

Joey

On Wed, Sep 15, 2021 at 10:13 AM Joey McCollum <jmccollum20140511@gmail.com>
wrote:

> Good suggestion! I removed my changes to publ-aut.lua for now and tried
> adding each of the two setups you described to publ-imp-author.mkvi (where
> it seemed to fit best). But simply specifying
>
> ```
> \definebtx
>   [sbl:\s!list:author]
>   [sbl:\s!list]
>   [\c!authorconversion=invertedfirst]
> ```
>
> in my custom rendering file does not access the invertedfirst setup,
> regardless of which of the two setups I use. Do I have to do something
> different to access it?
>
> Thanks!
>
> On Wed, Sep 15, 2021 at 4:18 AM Hans Hagen <j.hagen@xs4all.nl> wrote:
>
>> On 9/15/2021 5:06 AM, Joey McCollum via ntg-context wrote:
>> > All right, I figured out where I needed to make this change for it to
>> > take effect. The relevant script is publ-aut.lua. The code I needed to
>> > change was for the "oneauthor" function definition, which itself is
>> > located in the "btxauthor" function definition. My changes are detailed
>> > below:
>>
>> did you try to stay at the tex end? like:
>>
>> % \startsetups \s!btx:\s!cite:\s!author:invertedfirst
>> %     \ifnum\currentbtxauthorindex>\plusone
>> %        \btxsetauthorvariant{inverted}
>> %     \else
>> %        \btxsetauthorvariant{normal}
>> %     \fi
>> %     \fastsetup{\s!btx:\s!cite:\s!author:\btxauthorvariant}
>> % \stopsetups
>>
>> \startsetups \s!btx:\s!cite:\s!author:invertedfirst
>>      \ifnum\currentbtxauthorindex>\plusone
>>         \fastsetup{\s!btx:\s!cite:\s!author:inverted}
>>      \else
>>         \fastsetup{\s!btx:\s!cite:\s!author:normal}
>>      \fi
>> \stopsetups
>>
>>
>>
>> > ```
>> >          local function oneauthor(i,last,justone)
>> >              local author = split[i]
>> >              if index then
>> >                  ctx_btxstartauthor(i,1,0)
>> >              elseif last then
>> >                  ctx_btxstartauthor(i,1,0)
>> >                  ctx_btxsetconcat(0)
>> >                  if combiner == "invertedfirst" then
>> >                      if i == 1 then
>> >                          ctx_btxsetauthorvariant("inverted")
>> >                      else
>> >                          ctx_btxsetauthorvariant("normal")
>> >                      end
>> >                  else
>> >                      ctx_btxsetauthorvariant(combiner)
>> >                  end
>> >              else
>> >                  local state = author.state or 0
>> >                  ctx_btxstartauthor(i,max,state)
>> >                  ctx_btxsetconcat(concatstate(i,max))
>> >                  if combiner == "invertedfirst" then
>> >                      if i == 1 then
>> >                          ctx_btxsetauthorvariant("inverted")
>> >                      else
>> >                          ctx_btxsetauthorvariant("normal")
>> >                      end
>> >                  else
>> >                      ctx_btxsetauthorvariant(combiner)
>> >                  end
>> >              end
>> >              local initials = author.initials
>> >              if initials and #initials > 0 then
>> >                  ctx_btxsetinitials() --
>> > (concat(the_initials(initials,symbol)," "))
>> >              end
>> >              local firstnames = author.firstnames
>> >              if firstnames and #firstnames > 0 then
>> >                  ctx_btxsetfirstnames() -- (concat(firstnames," "))
>> >              end
>> >              local vons = author.vons
>> >              if vons and #vons > 0 then
>> >                  ctx_btxsetvons() -- (concat(vons," "))
>> >              end
>> >              local surnames = author.surnames
>> >              if surnames and #surnames > 0 then
>> >                  ctx_btxsetsurnames() -- (concat(surnames," "))
>> >              end
>> >              local juniors = author.juniors
>> >              if juniors and #juniors > 0 then
>> >                  ctx_btxsetjuniors() -- (concat(juniors," "))
>> >              end
>> >              if not index and i == max then
>> >                  if split.others then
>> >                      ctx_btxsetoverflow(1)
>> >                  else
>> >                      local overflow = #split - max
>> >                      if overflow > 0 then
>> >                          ctx_btxsetoverflow(overflow)
>> >                      end
>> >                  end
>> >              end
>> >              if combiner == "invertedfirst" then
>> >                  if i == 1 then
>> >                      ctx_btxsetup("inverted")
>> >                  else
>> >                      ctx_btxsetup("normal")
>> >                  end
>> >              else
>> >                  ctx_btxsetup(combiner)
>> >              end
>> >              ctx_btxstopauthor()
>> >          end
>> > ```
>> >
>> > I'll admit that the addition of entire if-else blocks around whether or
>> > not the combiner is a specific value may not be the best practice in
>> > terms of future maintenance (especially if similar index-dependent
>> > authorconversions are needed in the future). Alternatively, the
>> > "btxauthor" function could populate a "combiners" array of length "max"
>> > with a specific authorconversion for each author in the split; for most
>> > authorconversions, all entries in this array would be the same, but for
>> > authorconversions like "invertedfirst", the first entry would be
>> > different from the rest. Then, the "oneauthor" function could just
>> > reference combiners[i] instead of combiner.
>> >
>> > Joey
>> >
>> > On Fri, Sep 3, 2021 at 10:48 PM Joey McCollum
>> > <jmccollum20140511@gmail.com <mailto:jmccollum20140511@gmail.com>>
>> wrote:
>> >
>> >     Hi,
>> >
>> >     I mentioned this in an earlier e-mail but thought that now might be
>> >     a good time to describe this issue in detail. I'd like to define a
>> >     new authorconversion that renders the first author in a list
>> >     differently than the remaining authors in the list. Specifically,
>> >     I'd like to use the "inverted" authorconversion for the first author
>> >     and the "normal" authorconversion for the rest.
>> >
>> >     In the newer bibl-bib.lua file, I can see what I might have to
>> >     modify to accomplish this (I added the if combiner ==
>> >     "invertedfirst"  block):
>> >
>> >     ```
>> >     function authors.concat(author,combiner,what,settings)
>> >          if type(combiner) == "string" then
>> >              combiner = authors[combiner or "normal"] or authors.normal
>> >          end
>> >          local split = splitauthors(author)
>> >          local setting = settings[what]
>> >          local etallimit, etaldisplay, etaltext = 1000, 1000, ""
>> >          if setting then
>> >              etallimit   = settings.etallimit   or 1000
>> >              etaldisplay = settings.etaldisplay or etallimit
>> >              etalltext   = settings.etaltext    or ""
>> >          end
>> >          local max = #split
>> >          if max > etallimit and etaldisplay < max then
>> >              max = etaldisplay
>> >          end
>> >          if combiner == "invertedfirst" then
>> >              for i=1,max do
>> >                  if i == 1 then
>> >                      split[i] = authors.inverted(split[i],settings)
>> >                  else
>> >                      split[i] = authors.normal(split[i],settings)
>> >                  end
>> >
>> >              end
>> >          else
>> >              for i=1,max do
>> >                  split[i] = combiner(split[i],settings)
>> >              end
>> >          end
>> >          local result = bibtexconcat(split,settings)
>> >          if max < #split then
>> >              return result
>> >          else
>> >              return result .. etaltext
>> >          end
>> >     end
>> >     ```
>> >
>> >     Unfortunately, this doesn't seem to do anything. It's not clear to
>> >     me how bibl-bib.lua and bibl-bib.mkiv are being used by the other
>> >     publication support modules, if they're being used at all
>> >     (publ-ini.mkiv doesn't appear to register it, anyway). Is there
>> >     another file I'd have to change to make "invertedfirst" a working
>> >     authorconversion? Is there a similar block of code in publ-ini.lua
>> >     where I should be implementing this change instead?
>> >
>> >     Thanks!
>> >
>> >     Joey
>> >
>> >
>> >
>> ___________________________________________________________________________________
>> > 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
>> >
>> ___________________________________________________________________________________
>> >
>>
>>
>> --
>>
>> -----------------------------------------------------------------
>>                                            Hans Hagen | PRAGMA ADE
>>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
>> -----------------------------------------------------------------
>>
>

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

[-- Attachment #2: Type: text/plain, Size: 493 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:[~2021-09-15 17:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04  2:48 Joey McCollum via ntg-context
2021-09-15  3:06 ` Joey McCollum via ntg-context
2021-09-15  8:18   ` Hans Hagen via ntg-context
2021-09-15 14:13     ` Joey McCollum via ntg-context
2021-09-15 17:01       ` Joey McCollum via ntg-context [this message]
2021-09-15 18:56         ` Hans Hagen via ntg-context

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=CAGxRUG-2KcTb+wX1e8CEbgw2ZD8AJC3oa4ZWVZj2gxGipGFdBA@mail.gmail.com \
    --to=ntg-context@ntg.nl \
    --cc=j.hagen@xs4all.nl \
    --cc=jmccollum20140511@gmail.com \
    /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).