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: Org mode AUTHOR and KEYWORDS parsing seems instinctively "wrong"
Date: Thu, 13 May 2021 14:30:51 +0200	[thread overview]
Message-ID: <87v97myfwk.fsf@zeitkraut.de> (raw)
In-Reply-To: <57d2396b-e1e3-4096-9cd7-408f615a6839n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

We aim to stay close to the Emacs reference implementation, and the new
behavior is consistent with that of Org mode exporters as of org-version
9.4. The changelog for pandoc 2.10 has this info:

    + The behavior of the `#+AUTHOR` and `#+KEYWORD` export
      settings has changed: Org now allows multiple such lines
      and adds a space between the contents of each line. Pandoc
      now always parses these settings as meta inlines; setting
      values are no longer treated as comma-separated lists.
      Note that a Lua filter can be used to restore the previous
      behavior.

Here's a sample Lua filter to restore the old behavior (untested):


    --- Split a string on the given separator char.
    local function split_string (str, sep)
      local acc = pandoc.List()
      for substr in str:gmatch('([^' .. sep .. ']*)') do
        acc:insert(tostring(substr))
      end
      return acc
    end

    function Meta (meta)
      meta.author = split_string(pandoc.utils.stringify(meta.author,','))
      return meta
    end

See https://pandoc.org/lua-filters.html for more details.

HTH,
Albert

Garry Cairns <garryjcairns-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> tl;dr
> I'd expect KEYWORDS and AUTHOR to be parsed as MetaList types. But it seems
> they are individual strings/MetaInlines. Am I just misunderstanding the
> intent?
>
> Background
> I've used Slick as a static site generator for a little while
> (https://ilikewhenitworks.gitlab.io/). I don't post very often, and when I
> tried to write a post recently a rebuild of the code showed it no longer
> worked. I should be able to fix my personal issue by downgrading versions,
> but the root of the problem seems generally applicable. Given an org-mode
> file with headers:
>
> #+TITLE: Org Mode in Hakyll
> #+AUTHOR: Garry Cairns, Someone Else
> #+DATE: 2019-03-17
> #+KEYWORDS: emacs, haskell
> #+STARTUP: showall
>
> I'd expect KEYWORDS and AUTHOR to be parsed as MetaList types. But it seems
> they are individual strings both from how my static site builder now fails
> with an expected Array got String error, and from the following output:
>
> [nix-shell:~/code/ILikeWhenItWorks]$ pandoc -s -t native
> posts/2019-03-17-org-test.org
> Pandoc (Meta {unMeta = fromList [("author",MetaInlines [Str
> "Garry",Space,Str "Cairns,",Space,Str "Someone",Space,Str
> "Else"]),("date",MetaInlines [Str "2019-03-17"]),("keywords",MetaInlines
> [Str "emacs,",Space,Str "haskell"]),("title",MetaInlines [Str
> "Org",Space,Str "Mode",Space,Str "in",Space,Str "Hakyll"])]})
>
> This is with
>
> [nix-shell:~/code/ILikeWhenItWorks]$ pandoc --version
> pandoc 2.10.1
> Compiled with pandoc-types 1.21, texmath 0.12.0.2, skylighting 0.8.5
>
> Am I misunderstanding here?


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


  parent reply	other threads:[~2021-05-13 12:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 11:30 Garry Cairns
     [not found] ` <57d2396b-e1e3-4096-9cd7-408f615a6839n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2021-05-13 12:30   ` Albert Krewinkel [this message]
     [not found]     ` <87v97myfwk.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2021-05-13 12:56       ` Garry Cairns

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