From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/19302 Path: news.gmane.org!.POSTED!not-for-mail From: Albert Krewinkel Newsgroups: gmane.text.pandoc Subject: Re: Making a lua filter for short captions Date: Sat, 20 Jan 2018 10:40:46 +0100 Message-ID: <87efmkvpep.fsf@zeitkraut.de> References: <4be256f9-981f-4c16-92af-33bb4e3a1c40@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1516441159 4380 195.159.176.226 (20 Jan 2018 09:39:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 20 Jan 2018 09:39:19 +0000 (UTC) Cc: pandoc-discuss To: Greg Tucker-Kellogg Original-X-From: pandoc-discuss+bncBCZJF7XJTILRBPU5RTJQKGQEPA2PPSQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Jan 20 10:39:14 2018 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-wm0-f57.google.com ([74.125.82.57]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecpcI-0000qP-Ce for gtp-pandoc-discuss@m.gmane.org; Sat, 20 Jan 2018 10:39:14 +0100 Original-Received: by mail-wm0-f57.google.com with SMTP id f8sf679705wmi.9 for ; Sat, 20 Jan 2018 01:41:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516441279; cv=pass; d=google.com; s=arc-20160816; b=f1iXuejYRN3K5ThFCVNPGi6RR59yjl3jt3AasiG6m7sChoSZiOS0PvRghKvOxAquG+ OcvBBgdZGoPvL9aPaszWIEz1SvP8JjE0lWMo5pmjchZLvX1DfFUJhA8F2u75IgOeY+IR VGnPkU6uipRbn8mZyM484Ml7qIEOlbx6rrTCNIUPjWbofag2mtcVRXaqBQWmSQ2qmMc1 urjTwcAp8lXNBCTfEvVzp2xnvmks5HabjwbRUz2o7QlwxlDQq2bU1Is1FKlZzMcngsvh 62WmOmiQHBPNioSApMLGENcrUCSgrO+kHWiBDNLx54kVMKtptlCU92vhbICHn/7luCHf 4Ffg== 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:content-transfer-encoding :mime-version:message-id:in-reply-to:date:references:subject:cc:to :from:arc-authentication-results:arc-message-signature:sender :dkim-signature:arc-authentication-results; bh=4F2axA3hs46VO2ITBFpRdfI7VN7DVrS6z1djpCgZcmQ=; b=o7+B+b9StmPcjIoPhQqbuTR9f5qIeEHw6HSmE4u7vEsojFUYogTQJ3DcZ0FniOz3WD HykZ42LC0GjR7E+5BDdJ7lWeE1FBcnWTKirNDDOhRoO1LUsjaw8lLoD7hPdRYZGHux3v JRbSGEuoLg0eMo891n110L9EKjBGF3ZfDKQC0WaaneQwKeMklmjW62YK9+BcPYiRIF5i DyH2rB6iSBnYMOpQ+3tyNDnnGvyKK+Q90YombRnnJ8zI8AwKAK1UNRIyrGydu6mIVm1W QjmAVyDoQi45MS2djoS/xFEzSgx57FtlCSiweLK9OivFnaUrPMnyGGWWlDzHJn1dYjP7 y7 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.60.215 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeitkraut.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-transfer-encoding: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=4F2axA3hs46VO2ITBFpRdfI7VN7DVrS6z1djpCgZcmQ=; b=NfJIyRv8/ZPpZInpLVq78xkwe8IYYcgrwvUihxVXaN86ssjy3Ifzwz4mAsDvHgpSeM ZTUu3i/YzO2MeVio22ID9g8d8sv5iwkeHJZ8WtW72WFVbNIbKK91yxuSxB/YL/I0fQ21 hNh3g5t9+s+nvv53qoZGJXE3eIAhrv97gDU4SPhpCYzfti7PjunGn5pqN9QX3rbCD6hL gjubLEvVGa6ZslGIWuqeknGxnQvi/xVBMxg1i1DWQ8noDme/XNaij7MLxrD0srU/sZCb fMywmSWUAAh0CR6o080/wFgMeyi/0rHvhwurOWYP7vHrzyAROgSNvo3gBjdfxTIRwVbA nuKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:references:date :in-reply-to:message-id:mime-version:content-transfer-encoding :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=4F2axA3hs46VO2ITBFpRdfI7VN7DVrS6z1djpCgZcmQ=; b=F+UnnUgrOB20NshIkbJNVbSQeDUMqRHjEWNdH/ufOqW/xpVFCUp0eh0MpHVjslaXhG Vzbs552LZ7KIjsr2wPPhE5IMoka30tDzboUj1t5FKnTSqYKe7G4xbFgTlJvhfCqILT7Z kRgXx3vzeH6XlUxF4xsLI9zjpk2fp8dbeaWn1h6qoXEqD/eaSeKfUdjZTrrSHfG2/Y5a zzcjxBcIQu2RtKjBQjdTRBpC93I9TlzROno4zhhqbG5nnz1EK1cmTARmmKIODd6xkZX1 5ra0N+QxbOci4E4fad4R9uYqTz4JEtdr2L34DmWlGmYB5BJ2WFizgS6xTsqHS/krahu9 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AKwxytfe3CMXwwrhoPNi8yxff2X7bIz714zMZPck21E9t4Iwx2hLc41w ooCkgVrMHOld6dTwSpnFMuU= X-Google-Smtp-Source: AH8x224kMHdUIwjZQ/Iy+FUXligz+VOk64Q5nfoOKyA+najTm4VFmYj1PhQ9JPeUd/xTF38zZgNeiw== X-Received: by 10.28.156.133 with SMTP id f127mr7257wme.1.1516441278945; Sat, 20 Jan 2018 01:41:18 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.28.129.141 with SMTP id c135ls707780wmd.11.canary-gmail; Sat, 20 Jan 2018 01:41:17 -0800 (PST) X-Received: by 10.28.190.2 with SMTP id o2mr106958wmf.2.1516441277816; Sat, 20 Jan 2018 01:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516441277; cv=none; d=google.com; s=arc-20160816; b=N2yikPX8M8So2EUNpAaIay4Nztr+kfjSVbV/BuytFyV4TjOtDRE+NlCmf/9LNsuZ0J gi748CqJ0G18WP+cwFSs4t5QisY5UNL6/6vN9Fmv1mppWaF80pRopEcrvo4TrwBEsOn5 eyKVJI/KRsTa4HPZKMYXAG7sB8MoA2LOGWOtkMWmSXl8fiClzjfJyg9QstqnyiDY7ghR GSAl/3kZP44lYieOILz47/MZzLt5bg46qD7Wo9lEYxijrb92Nkzh5XI0nTFzSgoNqtaR mf/HuU1uh+OXmhxxDcAB0H3kHBxTZvWd2GnkYCrUcDRloraAKRaVGwMaOY9xHCm5Onyi apgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :references:subject:cc:to:from:arc-authentication-results; bh=jid+/K4opbkyfnIfCtbvQ1ekUpTaSgi5d/jBnkfrIOk=; b=Od+NUdDPr1w9QsQCAyYqRGnmeXGQi1c4/83UonrJ9GwKUlxPJ7D0sKt6YB1G+9d6J/ Ej8rwdHUkTBS/hBsGTemrRDHXDEJyUiqN5eyrAZgNHIVHgzkGXX8yYtf7mdUhSOcxxYv /kihdfkuLFsPSwavcG0juggF0obU5in1GlSG1CGGFzNC+W5AlnsD1cxpvsOW0JLAMn8k PHa7hktSRafIBFlZagaXgn0iqS87MUt5Rai9Q/IP93BAHSG65P5pA9AMXxZjcQEsP1Kx DyTzHfPF5ONW/gr0edv9tVNRGMAxm94QIJplfV/myYW9zufGMAF2Z7MHCwGvvWQrPcsm NCuA== 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.60.215 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeitkraut.de Original-Received: from mx2.mailbox.org (mx2.mailbox.org. [80.241.60.215]) by gmr-mx.google.com with ESMTPS id b10si378014wmc.0.2018.01.20.01.41.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jan 2018 01:41:17 -0800 (PST) Received-SPF: pass (google.com: domain of albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org designates 80.241.60.215 as permitted sender) client-ip=80.241.60.215; Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 4522341012; Sat, 20 Jan 2018 10:41:17 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id cQRBKkJ9NBKj; Sat, 20 Jan 2018 10:40:48 +0100 (CET) In-Reply-To: <4be256f9-981f-4c16-92af-33bb4e3a1c40-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> (Greg Tucker-Kellogg's message of "Fri, 19 Jan 2018 22:47:12 -0800 (PST)") 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.60.215 as permitted sender) smtp.mailfrom=albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeitkraut.de Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Spam-Checked-In-Group: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:19302 Archived-At: If you keep the normal Image element in your output, then pandoc will take care of image attributes, e.g.: =E2=8B=AE return pandoc.Plain { pandoc.RawInline('tex', '\\begin{figure}\n'), img, pandoc.RawInline('tex', '\\end{figure}\n'), } =E2=8B=AE This way one can still leverage pandoc's LaTeX writer functionality while getting more control over the output. I wrote a short-caption filter some month ago; I'd write it a bit differently nowadays: https://gist.github.com/tarleb/a57366474bbeef4c4c388adc19e85a41 A clean and working filter would be a good addition to https://github.com/pandoc/lua-filters. Please consider making a pull request when you get your filter working. Greg Tucker-Kellogg writes: > I'm trying to create a lua filter for short captions with latex output, s= o they can be used in `\listoffigures`. I have a filter that sort of kind o= f works for figures, > but it's obliterating other attributes (including the #fig needed for pan= doc-crossref). I I'd like to fix this filter > to preserve the other attributes, and would appreciate any guidance on do= ing so. > > I understand there is no current way to set attributes on tables, so that= would have to be manual. > > local utils =3D require 'pandoc.utils' > > function Para (figure) > if FORMAT =3D=3D"latex" then > if #figure.content =3D=3D 1 and figure.content[1].t =3D=3D 'Image' then > local img =3D figure.content[1] > if img.caption and img.attributes['short-caption'] then > local short =3D img.attributes['short-caption'] > local long =3D utils.stringify(img.caption) > return pandoc.Plain { > pandoc.RawInline('tex',"\\begin{figure}\n"), > pandoc.RawInline('tex','\\centering\n'), > pandoc.RawInline('tex',string.format("\\includegraphics{%s}\n",img.src)), > pandoc.RawInline('tex',string.format('\\caption[%s]{%s}\n',short,long)), > pandoc.RawInline('tex',"\\end{figure}\n") > } > end > end > end > end --=20 Albert Krewinkel GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 --=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 post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/87efmkvpep.fsf%40zeitkraut.de. For more options, visit https://groups.google.com/d/optout.