Skip to content

Convert boolean-like command-line variables to booleans like for metadata #10341

@bpj

Description

@bpj

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 foo pandoc.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?

Originally posted by @bpj in #10340 where @tarleb said I should report this as a bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions