public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* change alphabetized sort order of yaml metadata in markdown output
@ 2022-09-02 23:53 Tommy Keswick
       [not found] ` <15051A59-0166-4D56-BEA2-667D17BAD42D-pJ6Lu2hYgzjsYTE41BnpkpVzexx5G7lz@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Tommy Keswick @ 2022-09-02 23:53 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

When creating markdown files with external metadata (JSON or YAML) or inline, the resulting YAML metadata block always has its keys sorted alphabetically. Is there a way to change this behavior? I’d really like to have title appear first before a multiline abstract instead of at the bottom of the block.

-- 
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/15051A59-0166-4D56-BEA2-667D17BAD42D%40library.caltech.edu.


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

* Re: change alphabetized sort order of yaml metadata in markdown output
       [not found] ` <15051A59-0166-4D56-BEA2-667D17BAD42D-pJ6Lu2hYgzjsYTE41BnpkpVzexx5G7lz@public.gmane.org>
@ 2022-09-03  0:32   ` John MacFarlane
  0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2022-09-03  0:32 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Sorry, no.  The internal representation of metadata is an unordered map, so there is no way to retain the order you started with.

See https://github.com/jgm/pandoc/issues/7891

To make the output deterministic, we sort it in the Markdown writer (contextToYaml function).  Of course, we could adopt a different sorting convention, ensuring that `”title”`, `”author”`, and `”date”` come first.




> On Sep 2, 2022, at 4:53 PM, Tommy Keswick <tkeswick-pJ6Lu2hYgzjsYTE41BnpkpVzexx5G7lz@public.gmane.org> wrote:
> 
> When creating markdown files with external metadata (JSON or YAML) or inline, the resulting YAML metadata block always has its keys sorted alphabetically. Is there a way to change this behavior? I’d really like to have title appear first before a multiline abstract instead of at the bottom of the block.
> 
> -- 
> 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/15051A59-0166-4D56-BEA2-667D17BAD42D%40library.caltech.edu.

-- 
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/8A642A4E-02AE-4C7A-853C-237C28F3FE95%40gmail.com.


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

end of thread, other threads:[~2022-09-03  0:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 23:53 change alphabetized sort order of yaml metadata in markdown output Tommy Keswick
     [not found] ` <15051A59-0166-4D56-BEA2-667D17BAD42D-pJ6Lu2hYgzjsYTE41BnpkpVzexx5G7lz@public.gmane.org>
2022-09-03  0:32   ` John MacFarlane

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