From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/20318 Path: news.gmane.org!.POSTED!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: lua filter, convert Para into RawBlock Date: Wed, 06 Jun 2018 15:00:17 -0700 Message-ID: References: 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 1528322305 30249 195.159.176.226 (6 Jun 2018 21:58:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 6 Jun 2018 21:58:25 +0000 (UTC) To: =?utf-8?Q?Agust=C3=ADn_Mart=C3=ADn?= , pandoc-discuss Original-X-From: pandoc-discuss+bncBCJZJHG45QDBB75S4HMAKGQEOSPB2EY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 06 23:58:21 2018 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ua0-f190.google.com ([209.85.217.190]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQgRg-0007nA-V3 for gtp-pandoc-discuss@m.gmane.org; Wed, 06 Jun 2018 23:58:21 +0200 Original-Received: by mail-ua0-f190.google.com with SMTP id z33-v6sf2541479uah.4 for ; Wed, 06 Jun 2018 15:00:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1528322432; cv=pass; d=google.com; s=arc-20160816; b=nCm5FnnKXYJAGu6zVPXwA1ow5d93w6F/CvhK2fSSEx7PQE/iiRZ/bEk9UisRiQcsH8 vGQ9kVsA5u+A1TFkW1KaZR7rHZGzRvfqeRBbuExvL6cKe6AqanKURkAa8P+YYeo8Tmi9 IKshUMSXjCtSEloOzDz+ukXNAjhQl+iTYlXhoUjreP7PM/lEckHxK7MNOvjH21mVp+oF zJ6c3onbRQG8A0AAH6VWbBJ3oPApo5UQRjZLmq9Pj4r9KRBrp1JhBy+h+MEtvLWPNKdl qZuUsLwo+AIaT/31bVXHpEPY9Y9Tmk/7JQgPHiTJxcbRwWTGtLRPEGsW2hAzf6agpmaM CcTw== 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:date:references:in-reply-to:subject:to:from :arc-authentication-results:arc-message-signature:sender :dkim-signature:arc-authentication-results; bh=Z7vbZLTMDW4+fDq7+ctsWVKIrv28zwIbZqVvxLk5660=; b=PX/mllVWZriroPaERBdW4pS5d+HMvvvie6IGp/WLTiE6NB7uePFbc44BJ8gg6spe6W qXOrO/Y4BpQNizbZi/813Vh02KekHUsZSL/9CP0JhhBz+uM8a5iPkgWF4RaPUiOOj3yt 5v9Zd2ynZSMhYDkBDieUoKyZu3NEnVEyvu2msGLXZj7duEs3S6WJLEImMFODHkbKQzWA ODqZTym1/Zw9KYBEW+ea8L8ZZaLn2Hq2wlVvRj7GodTKaoWemirAEIbWmQoG2d9LKdKU gifvsE5cFoIcAwAU6OQnquQrN/0ZVh765b89WhiSrzBdYG/y6rSRv43/aO/Gi+5Nb5yi 6Z7Q= ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=M0edNNBi; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:400e:c00::232 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:in-reply-to:references:date: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=Z7vbZLTMDW4+fDq7+ctsWVKIrv28zwIbZqVvxLk5660=; b=qS1wA3I9HcpbS6aS/Ncu/LQjwz3TIHellUxTwWblK7l40GfBzyVVNhVJPollKUIP4p Ph7WwhdmJGM+cLQCSA2yXvKIn4SEoAd6bnKuNWklMoc3f3/Gx1fwWl1HN9AzMfup3cs7 +gKswFEZ6OCoG3XMUklqK7m8r+JuMM01XJYjSqUTHbIZYNfB/ossA2MfHHIAAUolwxAC UismcGkCaq6c+Pg3EQKWeEf9aJyeqec3kJ2mPzIkyXw8rWP+6hHoDisdujH2c5eG4ga9 v0ckC/4NvP635wp4vJeE/2uxrxuvKN6w1HKXj0SuOx2AgqoW23GsEC2rA7mIFyidNalh bmyw== 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:subject:in-reply-to:references :date: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=Z7vbZLTMDW4+fDq7+ctsWVKIrv28zwIbZqVvxLk5660=; b=ac/gK2lEbAA4wgMgISn/bqQVjOCX3g4osAZEPxsNhHF6/+c1eQAUHQrsNpaYDjdZer oc2r9Xodgzfz6buj7qQImfGmBb3eoNWN3KaxNZg/9xGgtTcXCkGPxwjS4oGml5FCKX/p atw41n/iaH18KDEmIYWTlQMxtCw2BPBpbjCmXrdSWrWeHk18ehPR10CB+jrnUCrtpVey 9M1DFgFibqwBBwIF7dU6sEWs3mu9BMI/qxesCyUzqFIh0QaG0+u99SZ9+176MlqFxScx oxC6TCGLnpioOF//EpmjGWbARu1Ox4TeG+5rpUj1BbzlUZqFFJDsHHlQV4YXUy0xmTBD Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APt69E3e/V1UtwfaHsbygcmPylwi4iLSbwLyxyM/i62M43uikP+hbE+C RQUzlc+GRzrALonSgLb5YlY= X-Google-Smtp-Source: ADUXVKJVFOJgHqlRAyRvh09d2ij8S029jrld7wxRoFbPoCuoSg3E8azWOPKnxb1FY/v24NgsHTsWUQ== X-Received: by 2002:ab0:4f0f:: with SMTP id n15-v6mr11678uah.7.1528322431968; Wed, 06 Jun 2018 15:00:31 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a1f:364b:: with SMTP id d72-v6ls433945vka.2.gmail; Wed, 06 Jun 2018 15:00:31 -0700 (PDT) X-Received: by 2002:a1f:f245:: with SMTP id q66-v6mr2170751vkh.22.1528322431014; Wed, 06 Jun 2018 15:00:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528322430; cv=none; d=google.com; s=arc-20160816; b=DlieKP5I531qQwTflWSAA/kZcXxE5nzUTlFhqnCQxLwMZP2kmcUe/mKcBf71jkx9vo 3EBPLhQ8/VTCrAe/+vkHtP4MNEnwBGybqfNvW6u2gNVSalnvZE0RXnnTEwfe9RVceIHh s2ZupqZByTsPkloWQdZYbZE8hbNjfIwXDEOPvLUKYi3hvKQI/MIZjxJc6iTejpVKsk/O 4EFLai0XeRxhHBN2o1fK9qfst+sn4FFSwnbsYXXAl05TY8cqxVqWADo5/qiAMgH51U3B YwP5B+Gb63nLP7X/b0ynCT0zl360eqlwgF3La4vTB3RQli5B8UkaPq6pqajIMZCOoneu hMOw== 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:date:references :in-reply-to:subject:to:from:dkim-signature :arc-authentication-results; bh=pyze1QvEvNDi2v4XqC6GesrcvwaZQRUXhPFU8Qaf/FE=; b=YiPTIt55kqYZHIOMPXcoafqpS9cGzlbCGcSVbPSE/fiih8P6dHra31MSa3ixouVTPK ld0mU4a/+tOODsJmy0HrSw/FPLsEUSf9vFiG8ItK/hHJoX9IOKi+LjZB6x4NAru022TB ymhRtX3wr+v9rfHXCL5T6349JIf1HqAox84d7+MvwcRerCe10T5B/gYBN79UKJWWoRSg Crqx2t5MpIlXdFkyKfZc9MYBWNP0ymnuoxVCc7gFVk6BM2k0i0caS1V3X6jrkqtgyu1n MeBaQ7kxLd3kOOdp2lr2OGUOG4CdorCvqwvYeqOc3MKdLD+a26l71H08JrLsBNP2yfSa kILA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=M0edNNBi; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:400e:c00::232 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org Original-Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com. [2607:f8b0:400e:c00::232]) by gmr-mx.google.com with ESMTPS id u190-v6si3907620vkd.5.2018.06.06.15.00.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 15:00:30 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:400e:c00::232 as permitted sender) client-ip=2607:f8b0:400e:c00::232; Original-Received: by mail-pf0-x232.google.com with SMTP id h12-v6so3790445pfk.11 for ; Wed, 06 Jun 2018 15:00:30 -0700 (PDT) X-Received: by 2002:a63:3c4b:: with SMTP id i11-v6mr3927614pgn.414.1528322430352; Wed, 06 Jun 2018 15:00:30 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id a20-v6sm3514040pfo.55.2018.06.06.15.00.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Jun 2018 15:00:28 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 66D98A17C; Wed, 6 Jun 2018 18:00:17 -0400 (EDT) In-Reply-To: X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com header.s=20150623 header.b=M0edNNBi; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:400e:c00::232 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@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-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:20318 Archived-At: Almost there! pandoc.RawBlock is a function that takes two arguments (not a table), so you should have () rather than {} after it. Agust=C3=ADn Mart=C3=ADn writes: > Hi, I'm new to lua, so forgive me if this is something basic. > > I'm trying to create a filter to convert the text "{{pagebreak}}" into a= =20 > docx page break. I know there are existing haskel filters for this, and= =20 > that I could also use a raw block directly in my docx (I've done that=20 > already) but I wanted to scratch my itch and do it with a lua filter. > > So far trying different approaches I have ended up with: > > -- file: macro-expander.lua > > function pagebreak_to_docx (inlines) > > if #inlines ~=3D 1 then return end > if inlines[1].t =3D=3D 'Str' and inlines[1].text =3D=3D "{{pagebreak}}" = then > return pandoc.RawBlock{"openxml", " />"} > end > end > > function Para (c) > return pagebreak_to_docx(c.content) > end > > Still when I run it with a basic example, I get the following error:=20 > > Could not read list: Could not get Block value: Expected a string but got= a=20 > nil > > Right at the exact place where the {{pagebreak}} occurs. > > Without the filter: > > $ echo -e "Raw Block in md: \n\n\`\`\`{=3Dopenxml}\n\n\`\`\` \n\nLua= =20 > Filter Test: \n\n{{pagebreak}}" | pandoc -f markdown -t native > [Para [Str "Raw",Space,Str "Block",Space,Str "in",Space,Str "md:"] > ,RawBlock (Format "openxml") "" > ,Para [Str "Lua",Space,Str "Filter",Space,Str "Test:"] > ,Para [Str "{{pagebreak}}"]] > > With the filter I'd expect the last Para to turn into a RawBlock but... > > $ echo -e "Raw Block in md: \n\n\`\`\`{=3Dopenxml}\n\n\`\`\` \n\nLua= =20 > Filter Test: \n\n{{pagebreak}}" | pandoc -f markdown -t native=20 > --lua-filter=3D"./macro-expander.lua" > > Error running filter ./src/servicio-gestion-software/macro-expander.lua: > Could not read list: Could not get Block value: Expected a string but got= a=20 > nil > > > Any help would be appreciated. > Thanks! > > --=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= email 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/msgi= d/pandoc-discuss/e32ff546-810b-4df6-a96e-71b07b753397%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. --=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/yh480k7enbh8y6.fsf%40johnmacfarlane.net. For more options, visit https://groups.google.com/d/optout.