Just noticed that Bastien Dumont faced a same issue writing a filter for
ODT output: https://github.com/jgm/pandoc/issues/7262 .
On Monday, April 18, 2022 at 2:15:06 PM UTC+1 Julien Dutant wrote:
> And related question, shouldn't the WriterOptions Lua constructor include
> a `standalone` field?
>
> On Monday, April 18, 2022 at 2:10:12 PM UTC+1 Julien Dutant wrote:
>
>> Hi all,
>>
>> I'm writing a new Lua filter to handle theorems and the like in various
>> format including JATS (https://github.com/jdutant/statement). Given the
>> following markdown and a suitable bibliography:
>>
>> ```markdown
>> ::: theorem
>> (from @article) Some very interesting fact holds.
>> :::
>> ```
>>
>> The filter is trying to generate a JATS statement (
>> https://jats.nlm.nih.gov/archiving/tag-library/1.1/element/statement.html
>> ):
>> ```xml
>> Some very interesting fact holds.
blocks. So if I build inlines list: >> inlines = { pandoc.RawInline('jats','
>> ``` >> >> Now I could of course stringify the title inlines first, add the title >> tags and insert the result in a RawBlock. But that's bad too, because the >> title inlines may contain things that aren't yet to be stringified like a >> citation. >> >> Is it necessary for the JATS writer to turn Plain elements into
ones? >> The HTML one doesn't, after all. >> >> At the moment my best approach is to use `pandoc.write` (thanks so much >> Albert for giving us this!) to convert the inlines on the spot. There are >> some issues with this though. >> >> * If something in the inlines needs to be handled by another filter it >> won't be handled properly. For instance, a pandoc-crossref crossreference >> will be turned into plain text and unretrievable. AFAIK my filter can't >> tell which other filters are run and can't pass them as WriterOptions >> anyway. >> * If I don't pass PANDOC_WRITER_OPTIONS, pandoc.write won't know which >> citation_mode to use, and may lack other relevant settings to write the >> inlines. >> * If I pass all of PANDOC_WRITER_OPTIONS, pandoc.write uses standalone >> mode if the document is in standalone mode, so I get a whole preamble >> within my label. Yet there is no standalone setting in WriterOptions, and I >> can unset it (I've tried to remove `template` but it didn't work). >> * So my best guess so far is to create a new WriterOptions by copying >> only those fields of PANDOC_WRITER_OPTIONS that might be useful to format >> the inlines. >> >> All in all, it's pretty heavy handed just to handle a label of inlines. >> Is there a better approach? Any chance that the JATS writer converts Plain >> blocks to plain blocks without
tags? >> >> Best, >> J >> >> -- 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/633d80cc-6595-4998-8f30-f15765ef1265n%40googlegroups.com.