public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Saving the pandoc AST
@ 2020-09-18 19:16 Brandon Barker
       [not found] ` <57b6a6d4-134c-4167-9f14-9c0a0607186an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Brandon Barker @ 2020-09-18 19:16 UTC (permalink / raw)
  To: pandoc-discuss


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

Hello!

I'm wondering if it is currently possible to save the pandoc AST of a 
document, and have it read in by pandoc at a later time? The use case I 
have in mind relates to preservation. It may be possible that an ancient 
file becomes difficult to read down the road, though presumably if the old 
version of pandoc that originally read it existed, it would be possible, if 
possibly more trouble. Whether or not this would be extremely useful would 
also depend on if pandoc is pretty good at reading old versions of the AST.

It looks like the AST includes pandoc-version 
<https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Version.html#t:Version>information 
already, which could be handy in principle, though I don't know if it is 
currently used as mentioned above in practice.

I didn't see the ability to save or read the AST listed as command-line 
options (though I may have missed it), but I'm more interested in the 
Haskell API anyway.

Thanks!

-- 
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/57b6a6d4-134c-4167-9f14-9c0a0607186an%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Saving the pandoc AST
       [not found] ` <57b6a6d4-134c-4167-9f14-9c0a0607186an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-18 19:41   ` Denis Maier
  2020-09-18 20:11   ` Albert Krewinkel
  2020-11-04  3:15   ` christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Maier @ 2020-09-18 19:41 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

Well saving is just
pandoc input -t native -o whatever.ast

I have never tried, but reading should work like this:

pandoc whatever.ast -f native ...


Am 18.09.2020 um 21:16 schrieb Brandon Barker:
> Hello!
>
> I'm wondering if it is currently possible to save the pandoc AST of a 
> document, and have it read in by pandoc at a later time? The use case 
> I have in mind relates to preservation. It may be possible that an 
> ancient file becomes difficult to read down the road, though 
> presumably if the old version of pandoc that originally read it 
> existed, it would be possible, if possibly more trouble. Whether or 
> not this would be extremely useful would also depend on if pandoc is 
> pretty good at reading old versions of the AST.
>
> It looks like the AST includes pandoc-version 
> <https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Version.html#t:Version>information 
> already, which could be handy in principle, though I don't know if it 
> is currently used as mentioned above in practice.
>
> I didn't see the ability to save or read the AST listed as 
> command-line options (though I may have missed it), but I'm more 
> interested in the Haskell API anyway.
>
> Thanks!
> -- 
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 
> <mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/57b6a6d4-134c-4167-9f14-9c0a0607186an%40googlegroups.com 
> <https://groups.google.com/d/msgid/pandoc-discuss/57b6a6d4-134c-4167-9f14-9c0a0607186an%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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/267d1225-d121-1254-c320-e3bddf1cfbd3%40mailbox.org.

[-- Attachment #2: Type: text/html, Size: 3504 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Saving the pandoc AST
       [not found] ` <57b6a6d4-134c-4167-9f14-9c0a0607186an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-09-18 19:41   ` Denis Maier
@ 2020-09-18 20:11   ` Albert Krewinkel
  2020-11-04  3:15   ` christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  2 siblings, 0 replies; 4+ messages in thread
From: Albert Krewinkel @ 2020-09-18 20:11 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Brandon Barker writes:

> I'm wondering if it is currently possible to save the pandoc AST of a
> document, and have it read in by pandoc at a later time?

There are even two ways: either use the Haskell representation with
`--to=native` or JSON with `--to=json`.

> The use case I have in mind relates to preservation. It may be
> possible that an ancient file becomes difficult to read down the road,
> though presumably if the old version of pandoc that originally read it
> existed, it would be possible, if possibly more trouble. Whether or
> not this would be extremely useful would also depend on if pandoc is
> pretty good at reading old versions of the AST.

Pandoc only reliably read the AST version against which it was compiled.
It's probably better to use a format which supports most of pandoc's AST
features for both input and output, e.g., Markdown or HTML.

You may find use in the nascent [ast-migrator] library and migrate an
archived AST to the current version. But the above still stands.

> I didn't see the ability to save or read the AST listed as command-line
> options (though I may have missed it), but I'm more interested in the
> Haskell API anyway.

Same as writing, just with `--from` (or `-f`) instead of `--to` / `-t`.


[ast-migrator]: https://github.com/tarleb/ast-migrator

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Saving the pandoc AST
       [not found] ` <57b6a6d4-134c-4167-9f14-9c0a0607186an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2020-09-18 19:41   ` Denis Maier
  2020-09-18 20:11   ` Albert Krewinkel
@ 2020-11-04  3:15   ` christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  2 siblings, 0 replies; 4+ messages in thread
From: christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2020-11-04  3:15 UTC (permalink / raw)
  To: pandoc-discuss


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

As others said it is doable. But I wouldn't suggest using the pandoc AST 
for preservation. The target formats is more stable than the pandoc API 
itself. Unlike something like TeX which has been declared feature complete 
and hence is a stable format, pandoc's AST is still a moving target.

It depends on your source format, but the best way to preserve it probably 
is itself, plus a reproducible recipe to generate an output (recipe should 
include the steps involved, dependencies including their versions.)

On Friday, September 18, 2020 at 12:16:30 PM UTC-7 Brandon Barker wrote:

> Hello!
>
> I'm wondering if it is currently possible to save the pandoc AST of a 
> document, and have it read in by pandoc at a later time? The use case I 
> have in mind relates to preservation. It may be possible that an ancient 
> file becomes difficult to read down the road, though presumably if the old 
> version of pandoc that originally read it existed, it would be possible, if 
> possibly more trouble. Whether or not this would be extremely useful would 
> also depend on if pandoc is pretty good at reading old versions of the AST.
>
> It looks like the AST includes pandoc-version 
> <https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Version.html#t:Version>information 
> already, which could be handy in principle, though I don't know if it is 
> currently used as mentioned above in practice.
>
> I didn't see the ability to save or read the AST listed as command-line 
> options (though I may have missed it), but I'm more interested in the 
> Haskell API anyway.
>
> Thanks!
>

-- 
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/d0fbac54-3906-40fe-9707-2b1065758541n%40googlegroups.com.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-04  3:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18 19:16 Saving the pandoc AST Brandon Barker
     [not found] ` <57b6a6d4-134c-4167-9f14-9c0a0607186an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-18 19:41   ` Denis Maier
2020-09-18 20:11   ` Albert Krewinkel
2020-11-04  3:15   ` christi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

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).