public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Checking the type of an AST value?
Date: Mon, 13 May 2019 08:27:53 +0200	[thread overview]
Message-ID: <CADAJKhCdciC-kCBRdahv8agj2Fv_0Y1PUhFW4CnRAMCLVP8M6g@mail.gmail.com> (raw)
In-Reply-To: <7568353b-0873-4270-9450-3f97f0377ddd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2358 bytes --]

You can check `element.t` (tag) like `if 'Str' == element.t`. It contains a
string equal to the element type name. It is also the best way to check
whether a table is an asset element: if it isn't `table.t` is most likely
`nil`.

Den mån 13 maj 2019 06:50Axel Rauschmayer <rauschma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:

> My use case is similar to the following code (taken from pagebreak.lua in
> the example repository):
>
> -- Turning paragraphs which contain nothing but a form feed
> -- characters into line breaks.
> function Para (el)
>   if #el.content == 1 and el.content[1].text == '\f' then
>     return newpage(FORMAT)
>   end
> end
>
> Question: How do I check the type of an AST value? Here, it is done by
> checking whether the value has the field .text (implying an instance of
> pandoc.Str), but that doesn’t always work. A work-around would be to walk
> the value and set a flag to true if a handler is invoked. But I was hoping
> there is something simpler.
>
> --
> 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/msgid/pandoc-discuss/7568353b-0873-4270-9450-3f97f0377ddd%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/7568353b-0873-4270-9450-3f97f0377ddd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/msgid/pandoc-discuss/CADAJKhCdciC-kCBRdahv8agj2Fv_0Y1PUhFW4CnRAMCLVP8M6g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 3898 bytes --]

  parent reply	other threads:[~2019-05-13  6:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13  4:48 Axel Rauschmayer
     [not found] ` <7568353b-0873-4270-9450-3f97f0377ddd-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-05-13  6:27   ` BPJ [this message]
     [not found]     ` <CADAJKhCdciC-kCBRdahv8agj2Fv_0Y1PUhFW4CnRAMCLVP8M6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2019-05-19  3:48       ` Axel Rauschmayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADAJKhCdciC-kCBRdahv8agj2Fv_0Y1PUhFW4CnRAMCLVP8M6g@mail.gmail.com \
    --to=melroch-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).