From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/101338 Path: news.gmane.org!.POSTED!not-for-mail From: Stanislav Sokolenko Newsgroups: gmane.comp.tex.context Subject: Re: Modifying bibliography entries using lua Date: Tue, 24 Jul 2018 11:41:10 -0300 Message-ID: <943e8809-b5df-45ea-a7b1-3de5520e10e3@sokolenko.net> References: <0c75e475-4775-b5c7-e4b8-3217234bf155@sokolenko.net> <6089de39-7d88-b256-8df5-ad309c4a3118@xs4all.nl> <17cae65b-7970-0827-e90a-2a97be436f43@sokolenko.net> <1a6a6c0b-f0cc-424e-2a54-1c6e262fcaa6@xs4all.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8563569572414879565==" X-Trace: blaine.gmane.org 1532443184 15277 195.159.176.226 (24 Jul 2018 14:39:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 24 Jul 2018 14:39:44 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 To: Hans Hagen , mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 24 16:39:40 2018 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fhyTU-0003r3-5Y for gctc-ntg-context-518@m.gmane.org; Tue, 24 Jul 2018 16:39:40 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id DF9474699D; Tue, 24 Jul 2018 16:41:25 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YBF8N04iD7d3; Tue, 24 Jul 2018 16:41:25 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id 2BFF846925; Tue, 24 Jul 2018 16:41:25 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id B722246925 for ; Tue, 24 Jul 2018 16:41:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hG46zRV-SlWS for ; Tue, 24 Jul 2018 16:41:23 +0200 (CEST) Original-Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id CF1DB46901 for ; Tue, 24 Jul 2018 16:41:12 +0200 (CEST) Original-Received: by mail-qt0-f194.google.com with SMTP id z8-v6so4317826qto.9 for ; Tue, 24 Jul 2018 07:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sokolenko-net.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=VP/xVzOofBQHy8CQYNrHMt7A5TwsRIs/w0egZeW/h0Q=; b=GQSBZmNDJbwoX0bA+QixS4Nz6WQchVyMNGUdlyjQDZMNK1ZSYjhmacNRa5mjMVYpUN 9TtH7tFs0EHddulAFrYOmbRcCqX4Kk4cks32IWsPzvabixcQ5yMQvfA2qnL9lXR5LKlH PlvvWds0dwSZXAUO4UrmARTuojGkuBiP5g+ENA4fhRhI/fOil7mXNQFTCWDR8plF0aiZ h9QeJ1tJ5g2/JPqiD54xjYtucgWJgp1MnqlaQFbfWel1hYIhP41r7PKSKbDAPkXJABcc 9gXUk+ZwzSxyOIMHn1e606yhHxCLoDbQbgbOS4+xyd0/8csGeRozZwPloPh14TZXjLuC u/xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=VP/xVzOofBQHy8CQYNrHMt7A5TwsRIs/w0egZeW/h0Q=; b=ukKtXEZExKEHC6rD+mvLiJLOyxEDK7GO1f4zE2s+XuHWx3F32YzLImLy5FzGEADX8V mb3AyUSdfrmoqErIZGj5XzBbMXzK21r3ETYmMAbyzX6R4wxo2x3qpT+uhKaUzfN8uY3v kFHK62GxIfjWNrtuxZIJ0DvwltQbxp7548r0GyBL/91rV8xRKTaLOvHqT9UVLWKyOmhS kqCb74W2qjduJoNUR6KRv7PSOg9Ldt40KH6qUKn9gn7XUih1FsFtFqJ/ZMieDlzwjrQE GPhHuuNB71L/O+FuNDCsvQsF4gGumhL7tNpr/ByES7L7tQ78HTkOGfVf92/1TUfhPRXs AQBA== X-Gm-Message-State: AOUpUlGOtaNQPwE+XI7p6yTYwNPrDeLFOu5VYNDFwZPANxh6b8hSb4DZ T+RBiapouvLtaxf0VLypXN/DTO3Orhc= X-Google-Smtp-Source: AAOMgpdBQM0SZt9mCjJensF1W1p2JQONvQo1XF0qrXXTRS8rZH7ifBkGhn9OCcqA89WYjYgqVCzMJQ== X-Received: by 2002:aed:3d74:: with SMTP id h49-v6mr17260699qtf.113.1532443271418; Tue, 24 Jul 2018 07:41:11 -0700 (PDT) Original-Received: from [129.173.116.159] (SSokolenko-2.peas.Dal.Ca. [129.173.116.159]) by smtp.gmail.com with ESMTPSA id v88-v6sm9624673qkv.63.2018.07.24.07.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jul 2018 07:41:11 -0700 (PDT) In-Reply-To: <1a6a6c0b-f0cc-424e-2a54-1c6e262fcaa6@xs4all.nl> Content-Language: en-US X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.org gmane.comp.tex.context:101338 Archived-At: This is a multi-part message in MIME format. --===============8563569572414879565== Content-Type: multipart/alternative; boundary="------------91F9B621C4C671219A71125E" Content-Language: en-US This is a multi-part message in MIME format. --------------91F9B621C4C671219A71125E Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit That's perfect, thank you! On 2018-07-23 06:32 PM, Hans Hagen wrote: > \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 I went with the following little extension to match and make bold multiple names: |\startbuffer[ref]@article{solo, author ={MyLast, MyFirst}, title ={Solo work}, journal ={Journal}, year ={2000}, month ={1}, volume ={1}}@article{co, author ={OtherLast, OtherFirst and MyLast, MyFirst and CoLast, CoFirst}, title ={Joint work}, journal ={Journal}, month ={1}, year ={2000}, volume ={1}}\stopbuffer\usebtxdataset[ref][ref.buffer]\setupbtx[dataset=ref]\definebtxrendering[ref][dataset=ref]\setupbtx[default:cite][alternative=authoryear, etallimit=1, authorconversion=normalshort]\startluacodeBoldNames ={{firstnames ="MyFirst", surnames ="MyLast"}, {initials ="C", surnames ="CoLast"}, }function document.CompareNames(reference, targets)-- Loop over targets for _, target in pairs(targets)do -- Loop over fields for key, value in pairs(target)do if reference[key]==nil then break end full_entry ='' for _, part in ipairs(reference[key])do full_entry =full_entry .. ' ' .. part end full_entry =string.sub(full_entry, 2)if full_entry ==value then return(true)end end end return(false)end function document.BoldNames(set, tag, aut)local c =publications.getcasted(set, tag, "author")if document.CompareNames(c[aut], BoldNames)then context("\\bf")end end \stopluacode\startsetupsbtx:list:author:normalshort \fastsetup{btx:list:author:concat}\begingroup\ctxluacode{document.BoldNames("\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\starttextCitations: \cite[solo]\cite[co]\startsubject[title=Bibliography]\placelistofpublications[ref][method=dataset]\stopsection\stoptext| Cheers, Stan --------------91F9B621C4C671219A71125E Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
That's perfect, thank you!

On 2018-07-23 06:32 PM, Hans Hagen wrote:
\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

I went with the following little extension to match and make bold multiple names:

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

@article{co,
  author = {OtherLast, OtherFirst and MyLast, MyFirst and CoLast, CoFirst},
  title = {Joint work},
  journal = {Journal},
  month = {1},
  year = {2000},
  volume = {1}
}
\stopbuffer

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

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

\startluacode
    BoldNames = {
        {firstnames = "MyFirst",
         surnames = "MyLast"},
        {initials = "C",
         surnames = "CoLast"},
    }

    function document.CompareNames(reference, targets)
        -- Loop over targets 
        for _, target in pairs(targets) do

            -- Loop over fields
            for key, value in pairs(target) do

                if reference[key] == nil then
                    break
                end

                full_entry = ''
                for _, part in ipairs(reference[key]) do
                    full_entry = full_entry .. ' ' .. part
                end
                full_entry = string.sub(full_entry, 2)

                if full_entry == value then
                    return(true)
                end
            end     
        end
        return(false)
    end 

    function document.BoldNames(set, tag, aut)      
        local c = publications.getcasted(set, tag, "author")

        if document.CompareNames(c[aut], BoldNames) then
            context("\\bf")
        end
    end
\stopluacode


\startsetups btx:list:author:normalshort
    \fastsetup{btx:list:author:concat}
    \begingroup

    \ctxluacode{document.BoldNames("\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 



\starttext

Citations: \cite[solo] \cite[co]

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

\stoptext
 
Cheers,

Stan

--------------91F9B621C4C671219A71125E-- --===============8563569572414879565== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f --===============8563569572414879565==--