Use Pandoc to format data.
The document.md
file contains data in its metadata YAML block and is its own
template:
$ pandoc --template document.md document.md
---
title: The document title
host:
- name: host-1
ip: 172.17.0.1
- name: host-2
ip: 172.17.0.2
---
Some hosts:
- host-1: 172.17.0.1
- host-2: 172.17.0.2
The result is a normal Markdown document that can be processed with Pandoc as usual.
The data can also come from an external file:
$ pandoc --template document.md hosts.yml document.md
---
title: The document title
host:
- name: host-1
ip: 172.17.0.1
- name: host-2
ip: 172.17.0.2
---
Some hosts:
- host-1: 172.17.0.1
- host-2: 172.17.0.2
- host-3: 172.17.0.3
Note: here the hosts
key in the metadata provided by document.md
is not
used because Pandoc is left-biased when merging multiple metadata blocks.
Several scripts are provided to change data format. For instance:
- From
hosts.json
(one object per line) to CSV, - From CSV to a Sqlite database,
- From a Sqlite database to JSON again (a list of objects),
- From a Sqlite database to YAML (using the previous script).