Skip to content

Conditionals evaluate truthiness #9661

Closed
@gl-eb

Description

@gl-eb

I've recently been working on a Typst template for Quarto via pandoc. I had a moment of confusion when I was setting a variable to false in the YAML block of the source file. My Typst template included the following conditional to pass the variable onto a Typst function in case it was set by the user.

$if(variable)$
  variable: $variable$,
$endif$

The Pandoc user guide states that "the if section is used if variable has a non-empty value". Thus I could not understand why the conditional was evaluating to false. After some research I learned that conditionals actually check for truthiness of the variable. This used to be reflected in the manual in the past (see #4631) but was removed again with commit ac4067f

Judging by the PR mentioned above this is expected behaviour. I would have found it helpful had the documentation explained this. I'm happy to draft a PR to add back the removed lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions