public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: Mixed Rawblock / Plain as Para in JATS output
Date: Mon, 18 Apr 2022 06:15:06 -0700 (PDT)	[thread overview]
Message-ID: <e40cf1d2-9f51-442b-8aa5-28905c6e77b6n@googlegroups.com> (raw)
In-Reply-To: <8589f717-fe73-4813-9126-6beba194a3f1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 3275 bytes --]

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
> <statement>
> <label>Theorem 1.1</label>
> <title>from Doe, J (2003)</title>
> <p>Some very interesting fact holds.</p>
> </statement>
> ```
>
> The problem I encounter is that the JATS writer converts pandoc.Plain to 
> <p> blocks. So if I build inlines list:
> inlines = { pandoc.RawInline('jats','<title>'), ... more inlines ..., 
> pandoc.RawInline('jats','<title>')}
>
> and try to insert it in the document with:
> blocks:insert( pandoc.Plain(inlines) )
>
> I get the unintended output:
> ```xml
> <p><title>from Doe, J (2003)</title><p>
> ```
>
> 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 <p> 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 <p> 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/e40cf1d2-9f51-442b-8aa5-28905c6e77b6n%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4909 bytes --]

  parent reply	other threads:[~2022-04-18 13:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-18 13:10 Julien Dutant
     [not found] ` <8589f717-fe73-4813-9126-6beba194a3f1n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-04-18 13:15   ` Julien Dutant [this message]
     [not found]     ` <e40cf1d2-9f51-442b-8aa5-28905c6e77b6n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-04-18 14:02       ` Julien Dutant
2022-04-18 14:03       ` Bastien DUMONT
2022-04-18 15:56         ` Julien Dutant

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=e40cf1d2-9f51-442b-8aa5-28905c6e77b6n@googlegroups.com \
    --to=julien.dutant-re5jqeeqqe8avxtiumwx3w@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).