1

Suppose I have YAML list (or other supported format) that I want to print as a comma-separated list in a markdown format.

data.yml:

---
items:
    - item1
    - item2
    - item3
---

template.markdown:

**Items**: $for(items)$$items$, $endfor$

How do I get rid of the trailing comma so I get:

**Items:** item1, item2, item3

Instead of:

**Items:** item1, item2, item3,

With:

pandoc -t markdown --template template.markdown -o output.md data.yml
Destroy666
  • 12,350
Brian McFarland
  • 233
  • 1
  • 3
  • 11

1 Answers1

1

Simply use $sep$ specifier instead of just hardcoded , in the template.

So:

**Items**: $for(items)$$items$$sep$, $endfor$

See for loop documentation.

Destroy666
  • 12,350