public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Lua filters: validating input and output formats
Date: Tue, 12 Jul 2022 12:38:48 +0200	[thread overview]
Message-ID: <87y1wyfwbv.fsf@zeitkraut.de> (raw)
In-Reply-To: <CADAJKhCzFH-VpPV=snQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


BPJ <melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I'm writing a filter which walks a table read from CSV, which are all
> read in as literal strings by Pandoc, and parses them with pandoc.read.
> In order to know which format to read the filter inspects a metadata
> field expecting the value to be the one to pass as second argument to
> pandoc.read. However there is easy way to validate that value before
> calling pandoc.read. To be sure I could create a table mapping every
> name returned by --list-input-formats to `true`, but it would seem that
> rather than every filter which needs this information (and conversely
> output formats for pandoc.write) maintaining its own lookup it would be
> better if the Lua API provided it, either as a pair of functions
> returning true if their argument is a valid format, or as (objects
> which act as) tables (sets) with valid formats mapped to true, which is
> something I assume Pandoc already has provision for internally. Does
> this seem like a good idea, or is my use case with the filter taking
> this info from the user too unusual to warrant this?

That seems like a good idea to me. I've created a PR:
https://github.com/jgm/pandoc/pull/8177


  parent reply	other threads:[~2022-07-12 10:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-09  9:48 BPJ
     [not found] ` <CADAJKhCzFH-VpPV=snQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-07-12 10:38   ` Albert Krewinkel [this message]
     [not found]     ` <87y1wyfwbv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-07-12 16:58       ` BPJ

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=87y1wyfwbv.fsf@zeitkraut.de \
    --to=albert+pandoc-9eawchwdxg8hfhg+jk9f0w@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).