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: file path as argument to pandoc.read()? (Especially to read YAML files into a (meta)data structure)
Date: Sat, 12 Mar 2022 19:33:46 +0100	[thread overview]
Message-ID: <878rtfgfzd.fsf@zeitkraut.de> (raw)
In-Reply-To: <CADAJKhASW-6XZ5cwUEerX3=O-vLCXhdAcQF=AbLU43WrMmxGRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>


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

> Is it possible in some way to pass a file path as argument to
> pandoc.read() in Lua filters or do you have to first get a string using
> Lua's io.open() and file:read()? If no would it maybe be a good idea to
> allow passing a table `{ file = 'path/to/file'}` instead of a string to
> read from a file?

I had been contemplated something similar in the past: My idea was to
provide functions to generate 'Sources', which is the structure passed
to custom readers. A `Source` argument would be easy to distinguish from
a string, and `read` could be made to parse the source.

My conclusion was that it might be nice, but that it's not worth the
effort for the time being.

> This is assuming that the problems I am having
> opening files with Lua from inside filters (I think the files are not
> found) may not be present from Haskell.

Huh, quite weird. Might be an encoding issue. Possibly related:
https://github.com/jgm/pandoc/issues/6077

> Also is there some way to read a YAML file into a (meta)data structure
> without manually making sure that the string starts/ends with
> `---\n`/`\n...\n`?

That's the hack I'm using as well. The best would probably be to install
a Lua library that binds to libyaml and to use that.


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


      parent reply	other threads:[~2022-03-12 18:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-12 11:29 BPJ
     [not found] ` <CADAJKhASW-6XZ5cwUEerX3=O-vLCXhdAcQF=AbLU43WrMmxGRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-03-12 18:33   ` Albert Krewinkel [this message]

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=878rtfgfzd.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).