Created
May 22, 2020 19:14
-
-
Save tarleb/7df9d5663457c0ea82e8444c71f14064 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| local yaml_template = "---\nDUMMY: %s\n---" | |
| function evaluate (str) | |
| local tag, value = str:match('^:(%a*):(.*)') | |
| if tag == 'lua' then | |
| return load( | |
| 'return ' .. value, | |
| "evaluating " .. value | |
| )() | |
| elseif tag == 'json' then | |
| return pandoc.read(yaml_template:format(value)).meta['DUMMY'] | |
| end | |
| return str | |
| end | |
| function Meta (meta) | |
| for key, value in pairs(meta) do | |
| if type(value) == 'string' then | |
| meta[key] = evaluate(value) | |
| end | |
| end | |
| return meta | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lua filter which evaluates specially marked metadata that has been passed through the command line. It allows to use either JSON or Lua.
Example:
Result: