I think you could use the template engine built into pandoc to do what you want to do.
t.tpl
:
$for(samples)$
- $samples.name$
$samples.samplecode$
$endfor$
t.md
:
---
samples:
- name: one
samplecode: |
```
function sample() {
return 1;
}
```
- name: two
samplecode: |
```
function sample() {
return 2;
}
```
---
Note: we put the code samples in code fences because pandoc interprets metadata values as markdown.
Then:
% pandoc --template t.tpl -f markdown -t markdown t.md
- one
function sample() {
return 1;
}
- two
function sample() {
return 2;
}