* Lua filters: validating input and output formats @ 2022-07-09 9:48 BPJ [not found] ` <CADAJKhCzFH-VpPV=snQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: BPJ @ 2022-07-09 9:48 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 1453 bytes --] 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? -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhCzFH-VpPV%3DsnQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 1778 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <CADAJKhCzFH-VpPV=snQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: Lua filters: validating input and output formats [not found] ` <CADAJKhCzFH-VpPV=snQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2022-07-12 10:38 ` Albert Krewinkel [not found] ` <87y1wyfwbv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Albert Krewinkel @ 2022-07-12 10:38 UTC (permalink / raw) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <87y1wyfwbv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>]
* Re: Lua filters: validating input and output formats [not found] ` <87y1wyfwbv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> @ 2022-07-12 16:58 ` BPJ 0 siblings, 0 replies; 3+ messages in thread From: BPJ @ 2022-07-12 16:58 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 2205 bytes --] Great. Thanks! Den tis 12 juli 2022 12:41Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> skrev: > > 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 > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/87y1wyfwbv.fsf%40zeitkraut.de > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhAh25W8A2vUYPFzEsy86_bVYBF5jPULPpAiNOTr_PP1PQ%40mail.gmail.com. [-- Attachment #2: Type: text/html, Size: 3340 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-12 16:58 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-07-09 9:48 Lua filters: validating input and output formats BPJ [not found] ` <CADAJKhCzFH-VpPV=snQkrhi8g_aCXYu4RDp0ghw3Pd8VmCXjzA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2022-07-12 10:38 ` Albert Krewinkel [not found] ` <87y1wyfwbv.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> 2022-07-12 16:58 ` BPJ
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).