From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/26754 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" Newsgroups: gmane.text.pandoc Subject: Re: How to access Span elements with lua filter based on their content Date: Fri, 6 Nov 2020 07:50:20 -0800 (PST) Message-ID: <84ffd932-2be5-4900-b115-58220e691dcbn@googlegroups.com> References: <871rh7trtg.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_724_2143114971.1604677820651" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31919"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCJOHJEKUQNBBPPBSX6QKGQEO5OXXJY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Nov 06 16:50:25 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f61.google.com ([209.85.161.61]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kb40P-0008Dr-Co for gtp-pandoc-discuss@m.gmane-mx.org; Fri, 06 Nov 2020 16:50:25 +0100 Original-Received: by mail-oo1-f61.google.com with SMTP id n5sf861209oov.16 for ; Fri, 06 Nov 2020 07:50:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=IxeqVO+O2qPTR9wv29s5hHfsfhnitWDpPIbpoJpiUBA=; b=ZY7V3oh/7eDzGWKUEZAfh42AbqIQefpys9LptweWGZIYFWxjqjqcUxUUG8xN8ZZabZ S87hXkRwjHMwp1rXHq8rPaPdLHqSDfh5bELpLhURxBg4XYw0k2TQL8QOB1LM//heLmR8 pQPV4ZXe1BcNTf4TQQy8Y6rRe0Jc8I3NV3etemWBgp0JIdY/UQEKgfnMmFkmlIXWPx0O 9CfiQJ5L15V55Hi5fXX1Bze82zWJjsF9d8aeyLlWb2GEz/RAnssWLeYDdZZ77Ujhsorn 35Ne7ZGeqVXTUAUUufJZxVNLEXdcyCe/iXmFEU/NvowBgWAJX+E7wkFkLoz1eK1EQCwz lUeg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=IxeqVO+O2qPTR9wv29s5hHfsfhnitWDpPIbpoJpiUBA=; b=m4VHvoUO23vSWOTvOYQcDfpzSi+Xkn4r4YGa9Urd1eWimqZHI9RtuA5op/H9fGiU+/ 2hpL9/Gmbi6ZcSCxxKl+Amyz/+7dAFSppLO6nalnEDZhcIuAoi8eVWDD3vzHRzzIIWNu 0nASvLcVLKOFd8FAJffRVkNemnUnMfEA1FUDy/ekeomQCg85DIG4zrS+a1HR3O58G7EI JyxrvMCBw88F7y7+6hQJG69aJuvY6GpjMzL7Dfr6FF95O/74JdZIz5qePPC6iEghzCHQ h7S2HRzmznj3ZKHnrXGL1tk+/Z73WEPIo6R7pJw452yq1XXcnMwBBcOrq+G765O4I4+P ma2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=IxeqVO+O2qPTR9wv29s5hHfsfhnitWDpPIbpoJpiUBA=; b=jCENe+k3+EPeyjQB8BhF0D28Ct4TFjrzV2gZnGY3KgL/xUHEX3bhpmJCfBgSSNsX7U IZF+2+gwmBrxJaP9cnkbUJKAiEWjYMHXuIC8udie+19WHrthA8i6ZXISQopdYgpoqTgZ I6lFaDRM/ecLTEqVk9VdLCRm+Se/VnrDpRegm0IeUuobSGN+H7CeNPXtpRbYLfyGIixz NZGSuswRuUpsCAiJX3pu6YdWi3NOQsPh4UAJ3rtpptWLSnLAw/3pOhYZYXDaX3lcveMu 7D8x1ftfubBeIMjnP+SFCNspLP7p06FAsshEAN/RgnwHzlj4KNe+N2TpkpUOz4ImZtW1 3FvA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM533ZPQOytXnn0y+Ymp88/SHew7NyxkY74RLdjllVpN7X3vcI9oOP Af+QWzH7+ne/73Ia356zKr0= X-Google-Smtp-Source: ABdhPJxJ/SsrzbwLxySM+6IXrHQLwRlweg32ffbkc87sVXNsDUHUP6+50l+r+s3TgJw6yUJoU5ZTww== X-Received: by 2002:a05:6830:19cc:: with SMTP id p12mr1549350otp.297.1604677824350; Fri, 06 Nov 2020 07:50:24 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:5f11:: with SMTP id f17ls389648oti.6.gmail; Fri, 06 Nov 2020 07:50:21 -0800 (PST) X-Received: by 2002:a9d:2483:: with SMTP id z3mr1545141ota.140.1604677821586; Fri, 06 Nov 2020 07:50:21 -0800 (PST) In-Reply-To: <871rh7trtg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: krulis.tomas.tk-Re5JQEeQqe8AvxtiuMwx3w@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:26754 Archived-At: ------=_Part_724_2143114971.1604677820651 Content-Type: multipart/alternative; boundary="----=_Part_725_945369933.1604677820651" ------=_Part_725_945369933.1604677820651 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Mr. Krewinkel, thank you for your help. The filter works great! The export option has made= =20 no difference for me, but I might be using it wrong (as it is always with= =20 me, I am learning working with Emacs, so I am probably doing something the= =20 way I shouldnt :D). The second part is difficult for me. Could you elaborate a little more=20 about how did you identified that those `'todo'` or `'TODO'` in the=20 TODO-Span as classes, and not attributes? This might be silly question, I= =20 guess this is somehow inspired by HTML, but it would be really helpfull for= =20 me to know how this element is represented in pandoc AST. And the element [String "TODO"] is a one-element list in pandoc-AST,=20 therefore it cannot be chacked as-is? Did I got the last part correctly? Regards, Tomas Dne =C4=8Dtvrtek 5. listopadu 2020 v 22:31:07 UTC+1 u=C5=BEivatel Albert Kr= ewinkel=20 napsal: > krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes: > > > I am using pandoc to convert `org-agenda` list of todos to `docx` and= =20 > `pdf` > > for my coworkers. File exported from `emacs org-agenda` can look like= =20 > that > > (simplified): > > > > `tasks.org` > > ``` > > * TODO Feed the cat > > ``` > > > > Pandoc native output of this file parsing is: > > > > ``` > > [Header 1 ("feed-the-cat",[],[]) [Span ("",["todo","TODO"],[]) [Str > > "TODO"],Space,Str "Feed",Space,Str "the",Space,Str "cat"]] > > ``` > > > > Now if I convert this to any output format, I get spurious "TODO" pando= c > > strings (that are present from `org-mode`). How can I get rid of this > > "TODO" string (preferably also with surrounding spaces)? > > Two options: > > 1. The org reader recognizes most org export options. So adding the > following line to your input file should be enough: > > #+OPTIONS: todo:nil > > See: https://orgmode.org/manual/Export-Settings.html > > 2. With a Lua filter you'll want > > function Span (span) > if span.classes:includes 'todo' then > return {} -- delete this element > end > end > > > So, how can I access, or match, `pandoc Span` elements based on their > > content? Where can I read more about this? > > _Just_ on their content is difficult for various reasons, but you can > compare AST elements using the normal `=3D=3D` Lua operator. The comparis= on > of elements happens in Haskell, where elements don't have identity. > > So `pandoc.Span {pandoc.Str 'hi'} =3D=3D pandoc.Span {pandoc.Str 'hi'}` > would be true, but `{pandoc.Str 'hi'} =3D=3D {pandoc.Str 'hi'}` would be > false, as lists are note treated as AST elements. We might change that > at some point. > > HTH, > > -- > 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 view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/84ffd932-2be5-4900-b115-58220e691dcbn%40googlegroups.com. ------=_Part_725_945369933.1604677820651 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello Mr. Krewinkel,
thank you for your help. The filter works great! T= he export option has made no difference for me, but I might be using it wro= ng (as it is always with me, I am learning working with Emacs, so I am prob= ably doing something the way I shouldnt :D).
The second part is difficul= t for me. Could you elaborate a little more about how did you identified th= at those `'todo'` or `'TODO'` in the TODO-Span as classes, and not attribut= es? This might be silly question, I guess this is somehow inspired by HTML,= but it would be really helpfull for me to know how this element is represe= nted in pandoc AST.
And the element [String "TODO"] is a one-elem= ent list in pandoc-AST, therefore it cannot be chacked as-is? Did I got the= last part correctly?
Regards, Tomas

Dne =C4=8Dtvrtek 5. list= opadu 2020=C2=A0v=C2=A022:31:07 UTC+1 u=C5=BEivatel Albert Krewinkel napsal= :
krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes:

> I am using pandoc to convert `org-agenda` list of todos to `docx` = and `pdf`
> for my coworkers. File exported from `emacs org-agenda` can look l= ike that
> (simplified):
>
> `tasks.org`
> ```
> * TODO Feed the cat
> ```
>
> Pandoc native output of this file parsing is:
>
> ```
> [Header 1 ("feed-the-cat",[],[]) [Span ("",[&q= uot;todo","TODO"],[]) [Str
> "TODO"],Space,Str "Feed",Space,Str "the&q= uot;,Space,Str "cat"]]
> ```
>
> Now if I convert this to any output format, I get spurious "T= ODO" pandoc
> strings (that are present from `org-mode`). How can I get rid of t= his
> "TODO" string (preferably also with surrounding spaces)?

Two options:

1. The org reader recognizes most org export options. So adding the
following line to your input file should be enough:

#+OPTIONS: todo:nil

See: https://orgmode.org/manual/Export-Settings.html

2. With a Lua filter you'll want

function Span (span)
if span.classes:includes 'todo' then
return {} -- delete this element
end
end

> So, how can I access, or match, `pandoc Span` elements based on th= eir
> content? Where can I read more about this?

_Just_ on their content is difficult for various reasons, but you can
compare AST elements using the normal `=3D=3D` Lua operator. The compar= ison
of elements happens in Haskell, where elements don't have identity.

So `pandoc.Span {pandoc.Str 'hi'} =3D=3D pandoc.Span {pandoc.St= r 'hi'}`
would be true, but `{pandoc.Str 'hi'} =3D=3D {pandoc.Str 'h= i'}` would be
false, as lists are note treated as AST elements. We might change that
at some point.

HTH,

--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124

--
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://groups.google.com/d= /msgid/pandoc-discuss/84ffd932-2be5-4900-b115-58220e691dcbn%40googlegroups.= com.
------=_Part_725_945369933.1604677820651-- ------=_Part_724_2143114971.1604677820651--