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: Inheritance / fallback for lua writers?
Date: Wed, 10 Jul 2019 10:12:48 +0200	[thread overview]
Message-ID: <87imsajojj.fsf@zeitkraut.de> (raw)
In-Reply-To: <0520a2cf-0235-4dd0-81d4-5109daedbb4c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

Hi Sven,

Sven Lauer writes:
>
> is there a way to "inherit" from another writer when coding a lua writer?
>
> [...]
>
> If this is not possible, is there any chance this could be included in
> the future?

Pandoc's writers expect full AST elements as inputs, which are not
available to the functions in custom writers: the nested elements have
already been turned into strings. There is thus no sane way to write
such a function. We would need to completely refactor custom writers to
make this possible. Using a filter is the best one can do right now.

> (Right now, I am using a lua filter that transforms the spans in question
> to RawInlines (a la
> https://ulyngs.github.io/blog/posts/2019-02-19-how-to-use-pandoc-filters-for-advanced-customisation-of-your-r-markdown-document/ )
> - but this seems hacky, since all I want is to specify how to output those
> spans in a particular output format ... which should be done in a writer,
> shouldn't it?

Lua filters are a good choice; use-cases like this match the intended
usage. If you'd like, you could add a line like this to the top of your
filter

    if not FORMAT:match 'tex$' then return {} end

This will ensure that the filter won't modify anything unless the target
format is LaTeX.

HTH,

Albert


  parent reply	other threads:[~2019-07-10  8:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 15:22 Sven Lauer
     [not found] ` <0520a2cf-0235-4dd0-81d4-5109daedbb4c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-07-10  8:12   ` Albert Krewinkel [this message]
     [not found]     ` <87imsajojj.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2019-07-10 11:09       ` Sven Lauer

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=87imsajojj.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).