From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29086 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=C3=A9ment_Aubert?= Newsgroups: gmane.text.pandoc Subject: Re: Passing multiple options to lua-filter from CLI Date: Fri, 20 Aug 2021 13:03:18 -0400 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000073fccb05ca00a609" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25748"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCM37TODUUORB4WA76EAMGQEDY7MWYA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Aug 20 19:03:49 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ua1-f64.google.com ([209.85.222.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mH7vp-0006WS-4t for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 20 Aug 2021 19:03:49 +0200 Original-Received: by mail-ua1-f64.google.com with SMTP id u9-20020ab07209000000b002ab978d1714sf2496082uao.23 for ; Fri, 20 Aug 2021 10:03:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1629479028; cv=pass; d=google.com; s=arc-20160816; b=bf6hXTNCsnvQ5Ujwd/iKdkk2YrosaEdU3oor2h8TpPz+JwElRrJw5H5ua1b1Ai33sf 66mBGk7QoO8pK1wueeLb6TEDWNUgmJIzLaw5u6Ge/ZNncrSMbzI7cXoDX1WcTYIe+H8V HKN2BEVD++kixNFLX7ntt9r15AE9y4GBehoZNH8PrkgbmVd/rMSfdQ5vbG25o2g4n1p6 Wahv6QsX2BTFW1F0h69RZYpLbilqFvwNYykjUSeyBQe5z/4BIOYdBdXjA4PBT83YYThW AnWoEBzV8urM6MMui6An4+DRyCHUrH8sDu3aUqoosoKv7PHieC/fq+g6oRW1vpdHZe2b h4ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=jyaglR4zFA9+3x8273MAkwqA131nswS82ljG+J/LWAM=; b=0FMvNIi6+9nr3/JW3/Iu9K4KxGDWcy6bNi7D4gnRXdAGiPgpF5jNQKHd3E2GdCSwHx n78G46Lo9AvKHV6sdC0sV738BZfxgCjwT69nSYMFtcS/o+31NrvrFoa7BpdkvMSDdGhc m8hxfGPzyFH1/c82OhfVRv1+lOAf2NON5WMqXOO0nizPY83GeFdB8Th2kCejzd1F62Xc UTXHlJBdjKyS4a98QO5vMR8KUaL1L2+57ODDvSGEaLyx49kzvu0C6PGbd73HqLcGZOt1 wyzw7tAzDIN0elhMgLyFhsdtXCLVIkabEL3b8BEE83CyXi+Z4kDH+AO6cB7yA8pGFrtl VrSg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fCeb63el; spf=pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::62f as permitted sender) smtp.mailfrom=aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject:to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=jyaglR4zFA9+3x8273MAkwqA131nswS82ljG+J/LWAM=; b=ZlV8pvb6MURelUe/T92KXPqdxaxkB1EVOHISpEF+6CJUEq2gi6FJ8lZQuHQDWbG0pt rIrgLqyJV/KD5CDBjmpTTNtioGzB/gHDcGApRLI+N20xoTsMxPnwJUg/xJmthM7LcJ9t 0mxAD8gjKutq6cUbFN3Y7WoPy5RqFrdJuU/OKR3MK+sWWf4oz8lPYGxCNLC08jErrKDP y8E/EW4r0PR2dqhudNVZiZvu9UIzjlpTVCZmhHqGGZSIo0weeFuJFVX29qktH11lIdM+ vfxsqEYfD4K4ozmRs6aJfAdV8orjDMm8wOAcJuwgxcu4vjHXhZDKDaGOrkbW4KgC6ZmF EDwA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=jyaglR4zFA9+3x8273MAkwqA131nswS82ljG+J/LWAM=; b=qjm3iUmdSYbUPTpzRzMOgxQlEav1c45jvqO1EU08sui9hEZ2FwUTrJvSqmpkKcnQyE dsNoFkiuBKJKFw/t9lKzDVHGiLQzEU/cxrKHW7pC3uElQMZdLNDGiv3x+JqGwHxcjlrL A/kDjWMZ3sr+NY3j162pcbcJm11iiFB51xhqa+xf4Wc//4zmPgyoSR26P3jS2VS+kjI3 5KGqA/VufJvXCR77iKYP05BmNdxj/V1qFfcq42ipwc81/EUb8x92EM9xKLXdqFehnoWg 6gbexjuJAyuuKYTnAL1Pg5j8TbunII5yo9oqWXS8n0Is1u5wV3X2OqnHh8uOK9llbiqF X+7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=jyaglR4zFA9+3x8273MAkwqA131nswS82ljG+J/LWAM=; b=Rj+knJatpcIMchOOI9M0SmSXDcELaSJQVC+imgZn3TPFl7X1DC5X3Omdw6v4tNTWmo MrYgG5XuRZ+fWfmGVngECPiVqAVEMTeOAYOjyOF0cq62G8sRc8okNh2Lx4RQdne4NArJ eUxj8UglF+XoY0vEGIQr2AMOg2VkHxZnibU7KM9RPN2OXkVHIspoMK2+WXk8C+sTxB7I Dc+1L291kDtbxbM4o4/uBpnDJURbYNaFRM7iNm8poIe9Vwl6XmaMBH+QX1Z86izUMzB7 lkqKSM/98IEJLxvlpgCkOFbZs/9MHirl00iQ22JfasI6EkYtu7xhJRCj60YqM+tGtlJZ TV/Q== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM5308tsY9H6+lv5J9BHhSFMFTdkfebl+ZpZnrG7QKPijWx+xPz8By cUXgWU4wrXRkFBGts9ayoPg= X-Google-Smtp-Source: ABdhPJxWWfNCuf0tSTBCZGdCPNyafwAbicYI2mbp3l3y7PAW6R8yN6hhOmjfUcnFYsZIo2qJqC5tHA== X-Received: by 2002:a05:6102:908:: with SMTP id x8mr18152897vsh.44.1629479028093; Fri, 20 Aug 2021 10:03:48 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ab0:c01:: with SMTP id a1ls1013287uak.4.gmail; Fri, 20 Aug 2021 10:03:46 -0700 (PDT) X-Received: by 2002:a9f:384f:: with SMTP id q15mr7173723uad.136.1629479026246; Fri, 20 Aug 2021 10:03:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629479026; cv=none; d=google.com; s=arc-20160816; b=rvzXTnoBj1+hllTiIiHsMux7d3S2MMTC/3SopugUAxDKBCBE39n9ugMoKd1ulYHjoK J5gAfXxTWu3qVGo7NQrVaOI2wBlbNZBKSV0GO+9xMQoVZDBIVzmP5ls6N0pwRPorYUHI QFFiQXDrGkrUR9tCyT4xHsBltpX4OEj/tT+IuldQXO1KmAoRtqwgXzPl51PU7nBUI5Pd jRNFm767HdGHvs31dL/fSnrJRgTuKmnSmVOZf/cIcL1FBLOAdkHzbUK/7eVS1UaouDdj oCm3U8OQrzHMJum1flgA/mAAnic56gNUf6lkint9mTDYqjnDaS2DkuLZI/KW7OmpZyAb dmXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Nr+XFhVoCn8ILQSVSkeyzwe/n+gTJ+6MRv9vpRm5sM8=; b=jwUdjdy0ygnDjya06Um/TxrjvvYB2OMwMmiPNtiIKClpjzc6s68RDxLY7Lj9ZJa7FH /qCnwid+SrUHWdjfd1TJ1vYtcc6A43m6o/w8YFOl53uWFb4Mc6lhSXjeZTkU4cLANM/K DQthlRFVE/PVWSFUggMqykq6QgtrfnYBdJSpvu33DNbDcxtw4KBBBjQD/2vrWG7iqFqw Z2FJLE+8IP9XYjZa2vYx7ODOLQLuFS7mGn/2S1NgiLh37AoQA9+A9UhIPI1K6IRaepu0 4KBC4O0L76NgdLHKCVZXfU6r7HeKEaW7hHwcQ7KPa0jGy2Jtm5GIumuC+ZiM/HWdHavX rSUw== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fCeb63el; spf=pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::62f as permitted sender) smtp.mailfrom=aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com. [2607:f8b0:4864:20::62f]) by gmr-mx.google.com with ESMTPS id p6si343729vsm.1.2021.08.20.10.03.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Aug 2021 10:03:46 -0700 (PDT) Received-SPF: pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::62f as permitted sender) client-ip=2607:f8b0:4864:20::62f; Original-Received: by mail-pl1-x62f.google.com with SMTP id w6so6285652plg.9 for ; Fri, 20 Aug 2021 10:03:46 -0700 (PDT) X-Received: by 2002:a17:90a:ab94:: with SMTP id n20mr5639811pjq.146.1629479024982; Fri, 20 Aug 2021 10:03:44 -0700 (PDT) In-Reply-To: X-Original-Sender: aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fCeb63el; spf=pass (google.com: domain of aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::62f as permitted sender) smtp.mailfrom=aubert.clement-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:29086 Archived-At: --00000000000073fccb05ca00a609 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks! pandoc -v pandoc 2.14.1 Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.11, citeproc 0.4.1, ipynb 0.1.0.1 User data directory: /home/caubert/.local/share/pandoc with the first line (about utils), I now get Error running filter templates/filters/default-code-class.lua: templates/filters/default-code-class.lua:1: module 'utils' not found: utilsis not one of pandoc's default packages no field package.preload['utils'] no file '/usr/local/share/lua/5.3/utils.lua' no file '/usr/local/share/lua/5.3/utils/init.lua' no file '/usr/local/lib/lua/5.3/utils.lua' no file '/usr/local/lib/lua/5.3/utils/init.lua' no file './utils.lua' no file './utils/init.lua' no file '/usr/local/lib/lua/5.3/utils.so' no file '/usr/local/lib/lua/5.3/loadall.so' no file './utils.so' stack traceback: [C]: in function 'require' templates/filters/default-code-class.lua:1: in main chunk make: *** [Makefile:281: build/labs/If/index.html] Error 83 without it, I get Error running filter templates/filters/default-code-class.lua: templates/filters/default-code-class.lua:7: attempt to index a nil value (global 'utils') stack traceback: templates/filters/default-code-class.lua:7: in function 'get_default_code_class' make: *** [Makefile:281: build/labs/If/index.html] Error 83 Le ven. 20 ao=C3=BBt 2021 =C3=A0 12:26, William Lupton a =C3=A9crit : > Inline... > > On Fri, 20 Aug 2021 at 17:06, Cl=C3=A9ment Aubert > wrote: > >> Thanks a lot for looking into it! >> It does not seem to produce the desired effect on my end. >> >> Could you explain how changing >> return {{Meta =3D get_default_code_class}, >> {Code =3D add_default_code_class}, >> {CodeBlock =3D add_default_code_class}} >> into >> return {{Meta=3Dget_default_code_class}, {CodeBlock=3Dadd_default_code_c= lass}} >> (as far as I can tell, this is the only modification) is supposed to >> achieve the desired effect? >> > > Ah, well I don't think that you included this in your original message, s= o > I thought that was the problem :). > > return {{Meta =3D get_default_code_class}, > {Code =3D add_default_code_class}, > {CodeBlock =3D add_default_code_class}} > > You are correct: the only difference is that you have Code. You could > combine Code and CodeBlock into a single pass, as in: > > return {{Meta=3Dget_default_code_class}, > {Code=3Dadd_default_code_class, CodeBlock=3Dadd_default_code_clas= s}} > > But it _does_ work for me! Maybe add some debug output? Here I'm using my > own inspect-like function but the standard inspect would probably be > similar. > > Pandoc version? I'm using 2.14.1. > > *% *cat default-code-class.lua > > utils =3D require 'utils' > > > local default_code_classes =3D {} > > > function get_default_code_class(meta) > > utils.temp('meta', meta) > > if meta['default-code-class'] then > > default_code_classes =3D > {pandoc.utils.stringify(meta['default-code-class'])} > > end > > end > > > function add_default_code_class(el) > > utils.temp(el.tag, el) > > if #(el.classes) =3D=3D 0 then > > el.classes =3D default_code_classes > > return el > > end > > end > > > return {{Meta=3Dget_default_code_class}, > > {Code=3Dadd_default_code_class, CodeBlock=3Dadd_default_code_clas= s}} > > > *% *LUA_PATH=3D../?.lua pandoc -L default-code-class.lua code.md -M > default-code-class=3D"c numberLines" > > (#) meta {default-code-class: "c numberLines"} > > (#) Code Code { > > attr: Attr { > > attributes: {} > > classes: {} > > identifier: "" > > } > > text: "inline code" > > } > > (#) CodeBlock CodeBlock { > > attr: Attr { > > attributes: {} > > classes: {} > > identifier: "" > > } > > text: "This is a code block." > > } > >

This is inline code.

> >
This is a code block.
> > Thanks! >> >> Le ven. 20 ao=C3=BBt 2021 =C3=A0 11:57, William Lupton >> a =C3=A9crit : >> >>> I think you need a two-pass filter, one to pick up the metadata and the >>> other to use it (this is because Meta is called nearly last). >>> >>> This works (I've re-ordered your functions and declared a local >>> variable, but this probably wasn't necessary). >>> >>> *% *cat default-code-class.lua >>> >>> local default_code_classes =3D {} >>> >>> >>> function get_default_code_class(meta) >>> >>> if meta['default-code-class'] then >>> >>> default_code_classes =3D >>> {pandoc.utils.stringify(meta['default-code-class'])} >>> >>> end >>> >>> end >>> >>> >>> function add_default_code_class(el) >>> >>> if #(el.classes) =3D=3D 0 then >>> >>> el.classes =3D default_code_classes >>> >>> return el >>> >>> end >>> >>> end >>> >>> >>> return {{Meta=3Dget_default_code_class}, >>> {CodeBlock=3Dadd_default_code_class}} >>> >>> >>> *% *pandoc -L default-code-class.lua code.md -M default-code-class=3D"c >>> numberLines" >>> >>>
>>> >>> On Fri, 20 Aug 2021 at 16:29, Cl=C3=A9ment Aubert >>> wrote: >>> >>>> Hi, >>>> >>>> This question relates to >>>> https://github.com/jgm/pandoc/issues/2104#issuecomment-595983954 >>>> There is a lua filter containing >>>> >>>> ``` lua >>>> function add_default_code_class(el) >>>> if #(el.classes) =3D=3D 0 then >>>> el.classes =3D default_code_classes >>>> return el >>>> end >>>> end >>>> >>>> function get_default_code_class(meta) >>>> if meta['default-code-class'] then >>>> default_code_classes =3D >>>> {pandoc.utils.stringify(meta['default-code-class'])} >>>> end >>>> end >>>> ``` >>>> >>>> and I'm trying to tweak it so that two classes can be passed from the >>>> command-line, eg. using >>>> >>>> --lua-filter default-code-class.lua -M default-code-class=3Dc, numberL= ines >>>> >>>> but can't find a way. >>>> >>>> Thanks! >>>> Cl=C3=A9ment. >>>> >>>> -- >>>> 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/c025fcc7-ff39-4993-97= f0-3dc8a7107724n%40googlegroups.com >>>> >>>> . >>>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "pandoc-discuss" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/pandoc-discuss/NrRuAcm1otQ/unsubscrib= e >>> . >>> To unsubscribe from this group and all its topics, 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/CAEe_xxgqyK6%2BT3kmb7s= NUckEJrS81cwm05iCvauKOA0Z3doRcg%40mail.gmail.com >>> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Group= s >> "pandoc-discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send a= n >> 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/CAPGHSezmvUZSEApp0fGCez= jUNcqSJJCMBaLGTaPUc86tSoUS0A%40mail.gmail.com >> >> . >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "pandoc-discuss" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/pandoc-discuss/NrRuAcm1otQ/unsubscribe. > To unsubscribe from this group and all its topics, 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/CAEe_xxgDzL%2BQjar4bGfUn= dO7Pq-RimWPmN5tzYSV3B6BUh0Nrg%40mail.gmail.com > > . > --=20 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 e= mail 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/CAPGHSewt%3DnK73AHRJ4C6yMs_rdRkcXAiJXeY0MEYo1pAxX4ugQ%40mail= .gmail.com. --00000000000073fccb05ca00a609 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks!

pandoc -v
pandoc = 2.14.1
Compiled with pandoc-types 1.22, texmath 0.12.3, skylighting 0.11= ,
citeproc 0.4.1, ipynb 0.1.0.1
User data directory: /home/caubert/.l= ocal/share/pandoc

with the first line (about u= tils), I now get

Error running filter templates/fi= lters/default-code-class.lua:
templates/filters/default-code-class.lua:1= : module 'utils' not found:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 utilsis = not one of pandoc's default packages
=C2=A0 =C2=A0 =C2=A0 =C2=A0 no = field package.preload['utils']
=C2=A0 =C2=A0 =C2=A0 =C2=A0 no fi= le '/usr/local/share/lua/5.3/utils.lua'
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 no file '/usr/local/share/lua/5.3/utils/init.lua'
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 no file '/usr/local/lib/lua/5.3/utils.lua'
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 no file '/usr/local/lib/lua/5.3/utils/init.lua= '
=C2=A0 =C2=A0 =C2=A0 =C2=A0 no file './utils.lua'
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 no file './utils/init.lua'
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 no file '/usr/local/lib/lua/5.3/utils.so'
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 no file '/usr/local/lib/lua/5.3/loadall.so'= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 no file './utils.so'
stack trac= eback:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 [C]: in function 'require'=C2=A0 =C2=A0 =C2=A0 =C2=A0 templates/filters/default-code-class.lua:1: in= main chunk
make: *** [Makefile:281: build/labs/If/index.html] Error 83<= /div>

without it, I get

Error r= unning filter templates/filters/default-code-class.lua:
templates/filter= s/default-code-class.lua:7: attempt to index a nil value (global 'utils= ')
stack traceback:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 templates/filters= /default-code-class.lua:7: in function 'get_default_code_class'
= make: *** [Makefile:281: build/labs/If/index.html] Error 83

<= /div>




Le=C2=A0ven. 20 ao=C3=BBt= 2021 =C3=A0=C2=A012:26, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> a =C3=A9crit=C2=A0:
=
Inline...

On Fri, 20 Aug 2021 at 17:06, Cl=C3=A9ment Aubert <aubert.clement@gmail= .com> wrote:
Thanks a lot for looking into it!
It do= es not seem to produce the desired effect on my end.

Could you explain how changing
return {{Meta =3D get_default_c= ode_class},
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {Code =3D add_default_code_class= },
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {CodeBlock =3D add_default_code_class}} <= br>
into
return {{Meta=3Dget_default_code_class}, {Code= Block=3Dadd_default_code_class}}
(as far as I can tell, this is t= he only modification) is supposed to achieve the desired effect?

Ah, well I don't think that you inclu= ded this in your original message, so I thought that was the problem :).

return {{Meta =3D get_default_code_class},
=C2=A0= =C2=A0 =C2=A0 =C2=A0 {Code =3D add_default_code_class},
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 {CodeBlock =3D add_default_code_class}}

You are correct: the only difference is that you have Code. You cou= ld combine Code and CodeBlock into a single pass, as in:

return {{Meta=3Dget_default_code_class},
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 {Code=3Dadd_default_code_class, CodeBlock=3Dadd_default_code_class}}

But it _does_ work for me! Maybe add some debug = output? Here I'm using my own inspect-like function but the standard in= spect would probably be similar.

Pandoc version? I= 'm using 2.14.1.

% = cat defau= lt-code-class.lua=C2=A0

utils =3D require 'utils&#= 39;


local default_code_classes =3D= {}


function get_default_code_clas= s(meta)

=C2=A0 utils.temp= ('meta', meta)

=C2=A0 if meta[&#= 39;default-code-class'] then

=C2=A0 =C2=A0 def= ault_code_classes =3D {pandoc.utils.stringify(meta['default-code-class&= #39;])}

=C2=A0 end=

end


function add_default_code_clas= s(el)

=C2=A0 utils.temp= (el.tag, el)

=C2=A0 if #(el.cl= asses) =3D=3D 0 then

=C2=A0 =C2=A0 el.= classes =3D default_code_classes

=C2=A0 =C2=A0 ret= urn el

=C2=A0 end=

end


return {{Meta=3Dget_default_co= de_class},

=C2=A0 =C2=A0 =C2=A0 =C2= =A0 {Code=3Dadd_default_code_class, CodeBlock=3Dadd_default_code_cla= ss}}


% = LUA_PATH= =3D../?.lua pandoc -L default-code-class.lua code.md -M default-code-class= =3D"c numberLines"

(#) meta {default-code-class: = "c numberLines"}

(#) Code Code {

=C2=A0 attr: Attr= {

=C2=A0 =C2=A0 att= ributes: {}

=C2=A0 =C2=A0 cla= sses: {}

=C2=A0 =C2=A0 ide= ntifier: ""

=C2=A0 }

=C2=A0 text: &quo= t;inline code"

}

(#) CodeBlock CodeBlock {

=C2=A0 attr: Attr= {

=C2=A0 =C2=A0 att= ributes: {}

=C2=A0 =C2=A0 cla= sses: {}

=C2=A0 =C2=A0 ide= ntifier: ""

=C2=A0 }

=C2=A0 text: &quo= t;This is a code block."

}

<p>This is <code clas= s=3D"c numberLines">inline code</code>.</p>=

<pre class=3D"c number= Lines"><code>This is a code block.</code></pre>


Thanks!

Le=C2=A0ven. 20 ao=C3=BBt 2021 = =C3=A0=C2=A011:57, William Lupton <wlupton-QSt+ys/nuMyEUIsrzH9SikB+6BGkLq7r@public.gmane.org> a =C3=A9cri= t=C2=A0:
I think you need a two-pass filter, one to pick up the metadata a= nd the other to use it (this is because Meta is called nearly last).
This works (I've re-ordered your functions and declared a = local variable, but this probably wasn't necessary).

% = cat defau= lt-code-class.lua=C2=A0

local default_code_classes =3D= {}


function get_default_code_clas= s(meta)

=C2=A0 if meta[&#= 39;default-code-class'] then

=C2=A0 =C2=A0 def= ault_code_classes =3D {pandoc.utils.stringify(meta['default-code-class&= #39;])}

=C2=A0 end=

end


function add_default_code_clas= s(el)

=C2=A0 if #(el.cl= asses) =3D=3D 0 then

=C2=A0 =C2=A0 el.= classes =3D default_code_classes

=C2=A0 =C2=A0 ret= urn el

=C2=A0 end=

end


return {{Meta=3Dget_default_co= de_class}, {CodeBlock=3Dadd_default_code_class}}


<= span style=3D"font-variant-ligatures:no-common-ligatures;color:rgb(128,42,2= 5)">% pandoc -L default-code-class.lua code.md -M default-code-class=3D"= c numberLines"

<pre class=3D"c number= Lines"><code></code></pre>

=

--
You received this message because you are subscribed to a topic in the Goog= le Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://g= roups.google.com/d/topic/pandoc-discuss/NrRuAcm1otQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to p= andoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgqyK6%2BT3= kmb7sNUckEJrS81cwm05iCvauKOA0Z3doRcg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAPGHSezmvUZSEApp0f= GCezjUNcqSJJCMBaLGTaPUc86tSoUS0A%40mail.gmail.com.

--
You received this message because you are subscribed to a topic in the Goog= le Groups "pandoc-discuss" group.
To unsubscribe from this topic, visit https://g= roups.google.com/d/topic/pandoc-discuss/NrRuAcm1otQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to p= andoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAEe_xxgDzL%2BQja= r4bGfUndO7Pq-RimWPmN5tzYSV3B6BUh0Nrg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://group= s.google.com/d/msgid/pandoc-discuss/CAPGHSewt%3DnK73AHRJ4C6yMs_rdRkcXAiJXeY= 0MEYo1pAxX4ugQ%40mail.gmail.com.
--00000000000073fccb05ca00a609--