I tried unsuccessfully to use a variable like -V foo as a boolean in Lua.
Something like -M foo, -M foo=true or -M foo=false does indeed result in a boolean value for that metadata field in Lua.
[EDIT: note that -M foo without a value results in a true value!]
With -V foopandoc.utils.type returns "Doc" for the value of PANDOC_WRITER_OPTIONS.variables.foo, but apparently that value stringifies to "true"! I find this doubly confusing as I had expected a boolean.
Using a variable for a filter switch would be more convenient as it could be accessed "directly" rather than writing a Meta filter which extracts the value from metadata and assigns it to a script-wide variable before running the main filter.
Obviously I could write code which converts a Doc to a string and a string which "looks like a bool" to a bool but should that really be necessary?
I tried unsuccessfully to use a variable like
-V foo
as a boolean in Lua. Something like-M foo
,-M foo=true
or-M foo=false
does indeed result in a boolean value for that metadata field in Lua. [EDIT: note that-M foo
without a value results in atrue
value!]With
-V foo
pandoc.utils.type
returns "Doc" for the value ofPANDOC_WRITER_OPTIONS.variables.foo
, but apparently that value stringifies to "true"! I find this doubly confusing as I had expected a boolean.Using a variable for a filter switch would be more convenient as it could be accessed "directly" rather than writing a Meta filter which extracts the value from metadata and assigns it to a script-wide variable before running the main filter.
Obviously I could write code which converts a Doc to a string and a string which "looks like a bool" to a bool but should that really be necessary?
Originally posted by @bpj in https://github.com/jgm/pandoc/discussions/10340 where @tarleb said I should report this as a bug.