Thanks Albert!

> We changed this to be more flexible when handling commands with
> filters.  Previously, the position of a `#+NAME: value` line in the
> text was completely lost; now we preserve it as a "raw Org block".

> We could think about adding an option to revert to the previous
> behavior, although that would add additional complexity, which I'm
> generally trying to avoid.

As I now know this was a deliberate choice I would also be against
adding an option to revert to the previous behavior.  Filters, in my
opinion, are a good enough way to handle this. (Thank you for the
filter, I already wrote one myself after posting my last message, but
yours is much more robust.)

> But we should definitely publish the below snippet on
> <https://pandoc.org/org.html> to make it easier to find and
> use. Could you add an issue to the issue tracker for one or both of
> these improvements?

I've looked at the Pandoc repository and saw that you have already
added this information to the =org.md= documentation, so I assume this
is now no longer relevant?

Best regards
Leo
Albert Krewinkel schrieb am Montag, 21. September 2020 um 10:14:49 UTC+2:
Hello Leo,

Leo Gaskin writes:

> It used to be possible (tested with Pandoc 2.7.3) to use the following Org
> syntax to set arbitrary template variables.
>
> ```
> #+VARIABLE: value
> ```
>
> However, with the latest version of Pandoc (2.10.1) this is no longer
> possible. Only a specific subset of variable prefixes (author, date, email,
> ...) are used to fill in the template variables and all others are
> interpreted as raw blocks.

We changed this to be more flexible when handling commands with filters.
Previously, the position of a `#+NAME: value` line in the text was
completely lost; now we preserve it as a "raw Org block".

You can get back the previous behavior by using the Lua filter given
below. Save it to a file and pass the file via the `--lua-filter`
command when calling pandoc.

> Would it be possible to revert to the old behavior? Interpreting the
> `#+VAR: val` syntax as raw blocks does not seem sensible to me, especially
> as certain variable names are treated specially.

We could think about adding an option to revert to the previous
behavior, although that would add additional complexity, which I'm
generally trying to avoid. But we should definitely publish the below
snippet on <https://pandoc.org/org.html> to make it easier to find and
use. Could you add an issue to the issue tracker for one or both of
these improvements?

Cheers,
Albert


The filter:

````````````````````````````````````````````````````````
local variables = {}

function RawBlock (raw)
if raw.format ~= 'org' then return nil end

local name, value = raw.text:match '#%+(%w+):%s*(.+)$'
if name and value then
io.stderr:write(name .. ': ' .. value)
variables[name] = value
end
end

function Meta (meta)
for name, value in pairs(variables) do
meta[name] = value
end
return meta
end
````````````````````````````````````````````````````````

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

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/35647032-aab2-48c1-bd5e-36e05f82bf6dn%40googlegroups.com.