public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Setting template variables in Org files
@ 2020-09-18 10:56 Leo Gaskin
       [not found] ` <d5b6d946-6efb-4ad4-a82e-effdeaddf492n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Gaskin @ 2020-09-18 10:56 UTC (permalink / raw)
  To: pandoc-discuss


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

Hello, new member here

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.

I currently use a template and Org file that make use of setting arbitrary 
template variables in an Org document for generating my CV and I would like 
to be able to keep using this setup.

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.

Alternatively, is there some other syntax I could use to set template 
variables as part of my Org document?

I would be very grateful for any help on this matter.


-- 
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/d5b6d946-6efb-4ad4-a82e-effdeaddf492n%40googlegroups.com.

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

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

* Re: Setting template variables in Org files
       [not found] ` <d5b6d946-6efb-4ad4-a82e-effdeaddf492n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-21  8:01   ` Albert Krewinkel
       [not found]     ` <878sd3lfrg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Albert Krewinkel @ 2020-09-21  8:01 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw; +Cc: Leo Gaskin

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


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

* Re: Setting template variables in Org files
       [not found]     ` <878sd3lfrg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2020-09-21 18:08       ` Leo Gaskin
       [not found]         ` <35647032-aab2-48c1-bd5e-36e05f82bf6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Leo Gaskin @ 2020-09-21 18:08 UTC (permalink / raw)
  To: pandoc-discuss


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

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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.

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

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

* Re: Setting template variables in Org files
       [not found]         ` <35647032-aab2-48c1-bd5e-36e05f82bf6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-09-22  8:20           ` Albert Krewinkel
  0 siblings, 0 replies; 4+ messages in thread
From: Albert Krewinkel @ 2020-09-22  8:20 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Leo Gaskin writes:

>> 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?

I'd still like to hear all suggestions for improvement, ideally in the
form of a PR. But if you think the new paragraph is sufficient, then
there is indeed no need for a new issue.

Cheers!
Albert

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


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

end of thread, other threads:[~2020-09-22  8:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18 10:56 Setting template variables in Org files Leo Gaskin
     [not found] ` <d5b6d946-6efb-4ad4-a82e-effdeaddf492n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-21  8:01   ` Albert Krewinkel
     [not found]     ` <878sd3lfrg.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-09-21 18:08       ` Leo Gaskin
     [not found]         ` <35647032-aab2-48c1-bd5e-36e05f82bf6dn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-09-22  8:20           ` Albert Krewinkel

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