From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/26765 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: Sun, 8 Nov 2020 10:20:28 -0800 (PST) Message-ID: <3feef49d-8473-4adf-abd7-de523ecb6661n@googlegroups.com> References: <871rh7trtg.fsf@zeitkraut.de> <84ffd932-2be5-4900-b115-58220e691dcbn@googlegroups.com> <87tuu2s2mw.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1060_1000426030.1604859628186" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18340"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCJOHJEKUQNBB3PNUD6QKGQESZW2MZI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sun Nov 08 19:20:34 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f56.google.com ([209.85.210.56]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kbpIn-0004eF-2p for gtp-pandoc-discuss@m.gmane-mx.org; Sun, 08 Nov 2020 19:20:33 +0100 Original-Received: by mail-ot1-f56.google.com with SMTP id u5sf3844144otb.3 for ; Sun, 08 Nov 2020 10:20:33 -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=7i3oFmwXbUAE/Sf9PFlpYSgj4DfV1kAetcLCY4eYhws=; b=DhmJzYGHWU8ZWpBm+j6qmjAw7DeXdZ1CNlPnv3casVcFdzuVyYtWnt+Bmdtr/06qkh ey92G/EyHlcEJyYzyeUfCiko4QFCqfDViS/xkIkt+MJC+llVtdf/LgiNQJ4TtZkOdelw qoxjYipRIwIpuaQxrACIsHrrzP+49Z4yMQhreMNOsUX/kWeSpmXye7HfWadfJEc338Gq XGZcVefJ4SOmXO0XHsb/S5P2iThSAD6wEfFtWHWcVZt1pTaJDXh84NLf/qpHWN3sfUUl cZRSSPJ9uYrZc+O+MfZKQPPNAM2NQki1cdog9A14vgSALVhDB1xW82b/AdCAw8LHBDED iD+w== 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=7i3oFmwXbUAE/Sf9PFlpYSgj4DfV1kAetcLCY4eYhws=; b=qSNpXt8xpJ67Cjs4V9cVdmy9lIhASkNCR9kXzQ3/oH5WvY3LOZJQuvYhoWaqGoUQdX 39+0kHzVYQm6rtqcDx6egvIYW9RarsJHV/JuAXMA1MLpp5vMmIYCxeZmwm4vzKcOBSfg 8fTlTFqSG3VscMvTw5wEfjD4R+/ZRjCNrZYd0lfTgeAzJp5gJYUSoe7IPSqVJUl0HftF Te03/9vbPhmcHEK6g4hlQRuF98htr/6HmacDxRiWZN7aZBNekqT+2YBUoSQLSvwzKi0N GVH6l+fsiELyuBlXd+LoLyYZq1HAjCyUeK5QNWSAGCJGaOk4pSvaSdGSkjsoVvdD2uNi cb6Q== 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=7i3oFmwXbUAE/Sf9PFlpYSgj4DfV1kAetcLCY4eYhws=; b=ZkzQto5C4nc1+MMsPNFGeT7+7H1giQmIqj1GOcNro4YK04gJM+eAizL8zDYUpwQRvp fOOeKla3+jTzftBfN5JOf+190+wYq6dWYyTsCGSJNDVGIMaBv9Lb9KWI11rykkBbermM PFoY1uNfZWuCfoMURmbX1qFS9scwZY0BAW9QyL1/9lOVeNOxYiazrTYkc+PNUo8nE/ti r+8Fs7HztyQbBhuSctEi3YRA+GV8j+1xw6n3yg4WBV4p4uGHQP038/C4N3PFZ3cZpPfO mcDEI1jHZA4XKvPtDV0OzKmEEwKCP0ICnpc5JK7rin3XrUwAmL/EKhYDsHF4mn4xf4p9 l2aQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531PoOi7/ET2LO4mxI684q5Kxo7npvAHF6YJi/9puIZIkduWWSd9 652jrKNzJ5wtNasMs6CIh8s= X-Google-Smtp-Source: ABdhPJwgEzH17bwDOvhwA+rpDPhuIw9YV8PqXJ0kIxiBxDdB8hqU6ABhtBywxkKucHv/Vx+p3gXydw== X-Received: by 2002:aca:b606:: with SMTP id g6mr6746088oif.22.1604859632163; Sun, 08 Nov 2020 10:20:32 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a9d:66cd:: with SMTP id t13ls449870otm.8.gmail; Sun, 08 Nov 2020 10:20:29 -0800 (PST) X-Received: by 2002:a9d:2f08:: with SMTP id h8mr7859233otb.117.1604859629133; Sun, 08 Nov 2020 10:20:29 -0800 (PST) In-Reply-To: <87tuu2s2mw.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:26765 Archived-At: ------=_Part_1060_1000426030.1604859628186 Content-Type: multipart/alternative; boundary="----=_Part_1061_490045871.1604859628186" ------=_Part_1061_490045871.1604859628186 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for offering help Mr. Krewinkel, but I should really first learn= =20 with Org-mode features and functions. I am yet lookig at the quick-start=20 guide and learning about what I actually **can** do with org-mode. I should= =20 think about hacking and modifying Emacs afterwards. About spans, I believe that their contents are not documented in such=20 concise way, as you have written now (at least not in user guide or in any= =20 filter documentation). Your explanation is perfectly understandable and=20 readable to me. Would it make sense to add this to the lua filter=20 documentation? Dne p=C3=A1tek 6. listopadu 2020 v 20:32:05 UTC+1 u=C5=BEivatel Albert Krew= inkel=20 napsal: > Hey Tomas, > > krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org writes: > > > thank you for your help. The filter works great! The export option has= =20 > made > > no difference for me, but I might be using it wrong (as it is always wi= th > > me, I am learning working with Emacs, so I am probably doing something= =20 > the > > way I shouldnt :D). > > Feel free to send me an example file and I can take a quick look. > > > The second part is difficult for me. Could you elaborate a little more > > about how did you identified that those `'todo'` or `'TODO'` in the > > TODO-Span as classes, and not attributes? > > That's a good question. A Span consists of two parts, the Attr and the > inline contents. Attr values are triples consisting of the element's id, > classes, and key-value attributes, in that order. > https://pandoc.org/lua-filters.html#type-attr > > If we look at > > >> > [Header 1 ("feed-the-cat",[],[]) [Span ("",["todo","TODO"],[]) [Str > >> > "TODO"],Space,Str "Feed",Space,Str "the",Space,Str "cat"]] > > we see that `["todo", "TODO"]` is the second element in the tuples, so > these are classes. We can now check the Lua filter docs for the Span > type to see how we can access the info: > https://pandoc.org/lua-filters.html#type-span > We find that Span elements have a `classes` field; the rest should be > discoverable by clicking and scrolling through the docs. > > The most difficult part is to know that the triples in the native output > are Attr values. I'm actually not sure if this is documented anywhere > but the Haskell source. Any confusion about this is very understandable. > > > And the element [String "TODO"] is a one-element list in pandoc-AST, > > therefore it cannot be chacked as-is? Did I got the last part correctly= ? > > Yes. Haskell lists are translated into plain Lua tables; the latter > follow the usual Lua comparison rules. Pandoc AST elements are special, > in that they have `__eq` metamethods which use Haskell's comparision > mechanism under the hood. Hence the difference in behavior. > > -- > 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/3feef49d-8473-4adf-abd7-de523ecb6661n%40googlegroups.com. ------=_Part_1061_490045871.1604859628186 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for offering help Mr. Krewinkel, but I should really first l= earn with Org-mode features and functions. I am yet lookig at the quick-sta= rt guide and learning about what I actually **can** do with org-mode. I sho= uld think about hacking and modifying Emacs afterwards.
About spans, I = believe that their contents are not documented in such concise way, as you = have written now (at least not in user guide or in any filter documentation= ). Your explanation is perfectly understandable and readable to me. Would i= t make sense to add this to the lua filter documentation?
Dn= e p=C3=A1tek 6. listopadu 2020=C2=A0v=C2=A020:32:05 UTC+1 u=C5=BEivatel Alb= ert Krewinkel napsal:
Hey Tomas,

krulis....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wri= tes:

> thank you for your help. The filter works great! The export option= has made
> no difference for me, but I might be using it wrong (as it is alwa= ys with
> me, I am learning working with Emacs, so I am probably doing somet= hing the
> way I shouldnt :D).

Feel free to send me an example file and I can take a quick look.

> The second part is difficult for me. Could you elaborate a little = more
> about how did you identified that those `'todo'` or `'= TODO'` in the
> TODO-Span as classes, and not attributes?

That's a good question. A Span consists of two parts, the Attr and = the
inline contents. Attr values are triples consisting of the element'= s id,
classes, and key-value attributes, in that order.
https://pandoc.org/lua-filters.html#type-attr

If we look at

>> > [Header 1 ("feed-the-cat",[],[]) [Span ("&= quot;,["todo","TODO"],[]) [Str
>> > "TODO"],Space,Str "Feed",Space,Str &q= uot;the",Space,Str "cat"]]

we see that `["todo", "TODO"]` is the second elemen= t in the tuples, so
these are classes. We can now check the Lua filter docs for the Span
type to see how we can access the info:
https://pandoc.org/lua-filters.html#type-span
We find that Span elements have a `classes` field; the rest should be
discoverable by clicking and scrolling through the docs.

The most difficult part is to know that the triples in the native outpu= t
are Attr values. I'm actually not sure if this is documented anywhe= re
but the Haskell source. Any confusion about this is very understandable= .

> And the element [String "TODO"] is a one-element list in= pandoc-AST,
> therefore it cannot be chacked as-is? Did I got the last part corr= ectly?

Yes. Haskell lists are translated into plain Lua tables; the latter
follow the usual Lua comparison rules. Pandoc AST elements are special,
in that they have `__eq` metamethods which use Haskell's comparisio= n
mechanism under the hood. Hence the difference in behavior.

--
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/3feef49d-8473-4adf-abd7-de523ecb6661n%40googlegroups.= com.
------=_Part_1061_490045871.1604859628186-- ------=_Part_1060_1000426030.1604859628186--