From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/30990 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Lua filter to modify captions in tables Date: Sat, 16 Jul 2022 15:33:31 +0200 Message-ID: <875yjxdvoz.fsf@zeitkraut.de> References: <0abadbc7-8cc9-4d67-92e2-fbd636f6cf3fn@googlegroups.com> <87a699dy1b.fsf@zeitkraut.de> <83057d17-1bda-4ec8-a96f-9567f975033en@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40796"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBUH6ZKLAMGQEPOL6OUQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jul 16 15:38:28 2022 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ed1-f58.google.com ([209.85.208.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oCi04-000AWD-HH for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 16 Jul 2022 15:38:28 +0200 Original-Received: by mail-ed1-f58.google.com with SMTP id f9-20020a056402354900b0043a902b7452sf5187809edd.13 for ; Sat, 16 Jul 2022 06:38:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657978708; cv=pass; d=google.com; s=arc-20160816; b=CRBTTd5c7LU1H2ypTtQ8qJOVRgNNZP72g/TscGwquMPB4Ntb17gwZ/Zvn0NR3lAqGV ElFd3mNur6Nf4DwePGzDzFnzis9kc3XiI6riK/snkKm2YK/ul3TmRfL3EkyZAsBAOVJv pebsWzGnvtE0nA8dDQyldHX9dcegqSiO0LHCPUSBpjrsPqpTUJWYD0ist0MAa0SA1g9V h8hR649mWS+17VryidL/9SjhfA3c7pbYf8BFpfhj7hIP+4fBvVMlvJtkrPOtMwtShpK7 fhJJwWYerODALCdTdxSCTrg0yqQNwERH4Uuts1dZMWkiTpvrG+zXU9Rl+QVbUvYFe9st lGDg== 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:mime-version:message-id :in-reply-to:date:subject:to:from:references:sender:dkim-signature; bh=pa1H6k+S3bBWZPSe9BvgumNHZ/SKYn1fK0IomREDuO4=; b=goQ70kPpafTfRQ+hg63LSdizjK5i54UyCmVtcHAdTn9l0Ap/njPhXAdRIejQuUZDIB s0Zq6kmFKdpnnkQd0TbHcFvHDXNlhKO8AyNO98c+oSqhCaaFSeEuNdU1BktS5wOfD6sa oO8949RxWRhOIkvxOHNG9UXNYC8ss0LZ6HQDN5WrMtznEFfk+61J98k2SWnbg5SZHOkg QdI5fISCGWJisrdgfjH/c9F6YPx/GxUbZFw0E2lW6opwTh72OEHMdYmSjjDWil37gU7w 2er+Xc5NrPfrPsqd1Kl/kBjE/jyMGvOvhRQMyFULlvXAULANxWk+GOmnbMaOxLPGS45R XrIA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:references:from:to:subject:date:in-reply-to:message-id :mime-version: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=pa1H6k+S3bBWZPSe9BvgumNHZ/SKYn1fK0IomREDuO4=; b=Tw1GXR3L+HFPDcJj7mbiRgQLsklffkSjsFZfDCheRcIf2uVFoi1bxfzl70G12ZpaXV 3wfILxiyrVbl+TxuQr0qVLOHUkwxSazGJic118ovQ5T55B6TP3/RDmKhizfEgLhhvk2n hflvQrItnaJsxJvAIEp84jw8ap9mzrmgAiVxUIIzBXUOXay8aZ9axZt8rDKRZSVZyyDx F/jMO4F+j4XxIeJPgBhwCIVwhs3njM8cUK4Z0s0lLL15ilUV22gFnQDwFdPqiDc2a3BP DoOKamyYxOyM1OKLQh5K0q78cqMZ7jCr250v7du8muid5YEzBKnhTL6udfLIfmve6sqF YX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:references:from:to:subject:date :in-reply-to:message-id:mime-version: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=pa1H6k+S3bBWZPSe9BvgumNHZ/SKYn1fK0IomREDuO4=; b=WnzJZLiWDr2uJWlTB25QvNG+6UGnLRNW7HBxU2sNOUxaRdrO7OUqlRwvWYSOTO7B+S OYIUdUfyBQ2aRAG/cR16OhbE+fBfbSkIvIMQ8BKqTNUXdwSwi0bRJD1g3Du6uhng2Jgn 5hFdNxdfSNVo/jNk4TpnF3+1YqKsQYcLeDssyEG7wUiRhp2zB8Jop+NVkn5keD6nh/pO 4J3ajMVPOSmG0ItKBckluplDhikXzA9y11CPceGpantLXaiXj7I2WHrKm3Bl0gJ+zBNQ 3yC1mJdFsgAG0btlLaZpdBOUCrOGxZhdu4BkzbYBdVOAja5zteZrVEtPC537F0ErC+xF DCDw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AJIora+53iAKmIxEK0+61rF29k0npvuLOLxo/P8YXvscXW2Xy8HJTYVo QY2qOgOl0/WHm2h2XAuKLoc= X-Google-Smtp-Source: AGRyM1tBZ2r5b+MnPWyXFBjGdfcOoOp2U00RctW8ihM2DR/LTPIN5+jjCec8Jvxsy8tLUEygUeE4Pw== X-Received: by 2002:a17:907:3e21:b0:72f:87c:efeb with SMTP id hp33-20020a1709073e2100b0072f087cefebmr5086525ejc.528.1657978708060; Sat, 16 Jul 2022 06:38:28 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a17:906:94c:b0:72f:1dfc:6374 with SMTP id j12-20020a170906094c00b0072f1dfc6374ls186830ejd.3.-pod-prod-gmail; Sat, 16 Jul 2022 06:38:23 -0700 (PDT) X-Received: by 2002:a17:907:96a2:b0:72e:e155:1331 with SMTP id hd34-20020a17090796a200b0072ee1551331mr12236198ejc.478.1657978703875; Sat, 16 Jul 2022 06:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657978703; cv=none; d=google.com; s=arc-20160816; b=Gtnd4Lnjq56+bNeV1zJIc0IPRTguS297YQCIQKrzHdDqtYy/nowEnoMTt45LC0YYQH SEIGZcw65plbhx5fM7gbQ/AL7B5vuBqR6S5dWfl60Uqqs4CDIBdeVIuSVoRHNAOqgjdv K30kYr8wxERUSHzXBwbofxHpxNPRuOEpltSRRRdypXAT25CUVcl2eGs7AE3OmSnGItU4 0YV5AdawDiR+72i7OTXv3+hjUZHW9+sYzdl5WACwbGy3GIb8aCwQeBIwuGEJtwwX3bPj sI9BVHhWfb+T6bnmykufqnQ7x+Sx+rpVYFPiQp1hS1b1MLIlX97RPZTiuqvWsiqM5PNp oKhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:message-id:in-reply-to:date:subject:to:from:references; bh=DoznHv6no5jKslz0mitsjjIqBqjIGhssIP34PKvRvaI=; b=vN/ubWfkHzmoDK3HZ4dJNhWX13+OzSQ4/Hl9fA/n8/SuBC+SBLO4AZkO90i97K9uij Lkuql2hcEwj6U49WPrxeqcpoyjsqmTkY8o2BlPDRwvfDsO3TScMQp0DWio2ku2XUsAuU NiMrdHAPrh3XHdPEIF4Z1pzpPFTm8OCvPIn1/dA4Hs/hkN6mNl8YDfkL+soepNLbTaxX amImuMBHSEVX6c0G8czWumFxfzCDSqvhsWtPpkq1LUOEn2B4Ne4L6ZLLo/71D8bkKk4o Ef8Rqe6cprA/QH7UVzBF4VOaBaMF8mkw83fbNLunCVAaMdGa3Q82BdaBb1s/JFZBjWt6 zQ1Q== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org Original-Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org. [80.241.56.151]) by gmr-mx.google.com with ESMTPS id i7-20020a50fc07000000b0043a2a36df0asi233533edr.1.2022.07.16.06.38.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Jul 2022 06:38:23 -0700 (PDT) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) client-ip=80.241.56.151; Original-Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4LlTnn3j6bz9sRK for ; Sat, 16 Jul 2022 15:38:21 +0200 (CEST) In-reply-to: <83057d17-1bda-4ec8-a96f-9567f975033en-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Rspamd-Queue-Id: 4LlTnn3j6bz9sRK X-Original-Sender: albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.56.151 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org 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:30990 Archived-At: Abhishek Ulayil writes: > Thanks albert, > > The filter works as intended, with your permission may I include it in > my github repo containing lua filters > : https://github.com/Abhi-1U/tex-lua-filters Please do. For formal reasons, I hereby license the code under the CC0 license. (I'd use "public domain", but it doesn't exist in my jurisdiction.) Cheers! > On Saturday, 16 July 2022 at 18:17:53 UTC+5:30 Albert Krewinkel wrote: > > Abhishek Ulayil writes: > > I was working on a lua filter to change the Table caption to add > > numbering > > > > ``` > > tables = 0 > > function Table(el) > > tables = tables + 1 > > local caption = "Table " .. tostring(tables) .. ": " .. > > pandoc.utils.stringify(el.caption) > > print(caption) > > > > el.caption = caption --facing problem here > > return el > > end > > ``` > > > > I am facing a problem to set the caption back to the element, > > > > what will be the correct way to set the caption. > Captions consist of two parts, the normal (long) caption and a > shorter > (short) description that can be used in a list of tables, for > example. > The problematic line should be changed to > el.caption.long = caption > As you noticed, it's not very user-friendly though, and we should > definitely improve that. > You'll probably want to keep the markup in the caption. I'm > attaching a > version that's a bit longer, but will preserve the caption's markup. > HTH! > ``` > tables = 0 > function Table(el) > tables = tables + 1 > local label = pandoc.Inlines("Table " .. tostring(tables)) > local caption = el.caption.long > if not caption[1] then > -- Table has no caption, just add the label > caption = pandoc.Blocks{label} > elseif caption[1].tag == 'Plain' or caption[1].tag == 'Para' then > -- Prepend label to paragraph > label:extend{pandoc.Str ':', pandoc.Space()} > caption[1].content = label .. caption[1].content > else > -- Add label as plain block element > label:extend{pandoc.Str ':', pandoc.Space()} > caption:insert(1, pandoc.Plain(label)) > end > el.caption.long = caption > return el > end > ``` -- Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124