-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed keyworded arguments in shortcodes
Keyworded arguments are obtained as Pandoc Inlines objects, and we parsed them to strings. However, in some cases (for example, `first_use`, `insert_links`, ...), we want to get a boolean value. When using a string, Lua often assumes a truthy value (if the string is not empty, etc.), which is not what we want! This commit adds a new helper function that converts common strings (`"true"`, `"false"`, `"yes"`, `"no"`, `"y"`, `"n"`) into their corresponding boolean value. The shortcode functions are also updated to get their keyworded arguments as boolean (by using this new helper) when necessary. Also fixed the way we handle default values for such arguments: we previously used `value = value or Options["value"]`, which works fine with nil/non-nil values, but wrongly considers a `false` value as an empty value (and replaces it with the default)! We keep the `x = x or ...` for strings, but replace with an if for boolean values.
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters