{"action":"created","issue":{"url":"https://api.github.com/repos/jgm/pandoc/issues/1950","repository_url":"https://api.github.com/repos/jgm/pandoc","labels_url":"https://api.github.com/repos/jgm/pandoc/issues/1950/labels{/name}","comments_url":"https://api.github.com/repos/jgm/pandoc/issues/1950/comments","events_url":"https://api.github.com/repos/jgm/pandoc/issues/1950/events","html_url":"https://github.com/jgm/pandoc/issues/1950","id":57878939,"node_id":"MDU6SXNzdWU1Nzg3ODkzOQ==","number":1950,"title":"Feature request: use variables in document body text","user":{"login":"DaveJarvis","id":2131950,"node_id":"MDQ6VXNlcjIxMzE5NTA=","avatar_url":"https://avatars3.githubusercontent.com/u/2131950?v=4","gravatar_id":"","url":"https://api.github.com/users/DaveJarvis","html_url":"https://github.com/DaveJarvis","followers_url":"https://api.github.com/users/DaveJarvis/followers","following_url":"https://api.github.com/users/DaveJarvis/following{/other_user}","gists_url":"https://api.github.com/users/DaveJarvis/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveJarvis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveJarvis/subscriptions","organizations_url":"https://api.github.com/users/DaveJarvis/orgs","repos_url":"https://api.github.com/users/DaveJarvis/repos","events_url":"https://api.github.com/users/DaveJarvis/events{/privacy}","received_events_url":"https://api.github.com/users/DaveJarvis/received_events","type":"User","site_admin":false},"labels":[{"id":113084,"node_id":"MDU6TGFiZWwxMTMwODQ=","url":"https://api.github.com/repos/jgm/pandoc/labels/enhancement","name":"enhancement","color":"fbca04","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2015-02-17T03:20:50Z","updated_at":"2018-10-07T16:04:44Z","closed_at":null,"author_association":"NONE","body":"**variables.yaml**:\n\n```\n\n---\nprotagonist:\n- first: Ishmael\nantagonist:\n- first: Moby-Dick\n- classification: whale\n- colour: white\n- possessive: #{protagonist.first}'s\n\n---\n```\n\n(Only back references allowed for one-pass parsing.)\n\n**chapters/1.md**:\n\n```\n\"Call me #{protagonist.first}. I won't rest until I've mounted #{antagonist.possessive} fluke on my roof. That giant #{antagonist.color} fish of the sea is my nemesis.\"\n```\n\nThen `pandoc variables.yaml chapter/1.md` would write the following HTML to stdout, with the variables from the markdown file substituted using the values from the YAML file:\n\n```\n<html>\n<body>\n<p>\n\"Call me Ishmael. I won't rest until I've mounted Moby-Dick's fluke on my roof. That giant #{antagonist.color} fish of the sea is my nemesis.\"\n</p>\n</body>\n</html>\n```\n\nSince color couldn't be found (due to the variable name being _colour_), no variable substitution is made. To stderr, a listing of all missing variables:\n\n```\n#{antagonist.color}\n```\n\nIf this is already possible with pandoc, please link to the documentation showing a clear example for how to accomplish this task (without using templates, as they are inappropriate for this situation). \n\nIdeas on how to write a preprocessor for markdown documents (that could then be piped to pandoc) are also quite welcome.\n"},"comment":{"url":"https://api.github.com/repos/jgm/pandoc/issues/comments/427664614","html_url":"https://github.com/jgm/pandoc/issues/1950#issuecomment-427664614","issue_url":"https://api.github.com/repos/jgm/pandoc/issues/1950","id":427664614,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzY2NDYxNA==","user":{"login":"DaveJarvis","id":2131950,"node_id":"MDQ6VXNlcjIxMzE5NTA=","avatar_url":"https://avatars3.githubusercontent.com/u/2131950?v=4","gravatar_id":"","url":"https://api.github.com/users/DaveJarvis","html_url":"https://github.com/DaveJarvis","followers_url":"https://api.github.com/users/DaveJarvis/followers","following_url":"https://api.github.com/users/DaveJarvis/following{/other_user}","gists_url":"https://api.github.com/users/DaveJarvis/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveJarvis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveJarvis/subscriptions","organizations_url":"https://api.github.com/users/DaveJarvis/orgs","repos_url":"https://api.github.com/users/DaveJarvis/repos","events_url":"https://api.github.com/users/DaveJarvis/events{/privacy}","received_events_url":"https://api.github.com/users/DaveJarvis/received_events","type":"User","site_admin":false},"created_at":"2018-10-07T16:04:44Z","updated_at":"2018-10-07T16:04:44Z","author_association":"NONE","body":"> (Although it may not satisfy everyone's needs!)\r\n\r\nThere are a few key aspects that would make this feature more versatile:\r\n\r\n* **Filename.** Provide the name of the file containing variables on the command line. Such as: \r\n    * `pandoc document.md --filter pandoc-mustache variables.yaml`\r\n* **Delimiters.** Ability to define the start and end token delimiters, as hard-coding is an unnecessary restriction. See:\r\n    * `{{...}}` - [Assemble](http://assemble.io/docs/Built-in-Variables.html), [Handlebars]([url](https://github.com/helpers/helper-markdown)), and others. Seems to be gaining popularity.\r\n    * `#{...}` - [Aaron Parecki](https://aaronparecki.com/2012/09/01/2/some-enhancements-to-markdown)\r\n    * `$(...)` - Jekyll and Julia?\r\n    * `${...}` - [Scrivenvar](https://github.com/DaveJarvis/scrivenvar), explicit [bash variables](https://unix.stackexchange.com/a/358275/26227), and [Apache Camel REST](https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/7.0-tp/html/apache_camel_development_guide/restservices) services configuration\r\n    * `` `r#x(v$...)` `` - Scrivenvar's R Markdown (.Rmd) expressions (see [knitr](http://kbroman.org/knitr_knutshell/pages/Rmarkdown.html))\r\n    * `[%...]` - [Multimarkdown](https://ia.net/writer/support/general/markdown-guide)?\r\n    * `$...$` - [pandoc](https://pandoc.org/) variables\r\n    * `+r ...+` - [Knitr/AsciiDoc](http://kbroman.org/knitr_knutshell/pages/asciidoc.html)\r\n    * Implies:\r\n        * `pandoc document.md --filter pandoc-mustache -f variables.yaml -delim '${' -delim '}'`\r\n* **String interpolation.** This [YAML preprocessor](https://bitbucket.org/djarvis/yamlp/src/master/README.md) first performs recursive string interpolation before attempting to substitute back into the document. The algorithm is a trivial [8 lines of code](https://bitbucket.org/djarvis/yamlp/src/master/src/main/java/com/whitemagicsoftware/yamlp/parser/YamlParser.java#lines-242), once the data structures are defined.\r\n"}}
{"actor":{"display_login":"DaveJarvis"}}