markdown-to-json-transformer
Tactical Technology Collective Markdown to JSON transformer
Last updated 9 months ago by laurentd .
GPL-3.0 · Repository · Original npm · Tarball · package.json
$ cnpm install markdown-to-json-transformer 
SYNC missed versions from official npm registry.

Description

Takes files with Markdown and (YAML) frontmatter and transforms them to JSON. Can optionally transform to HTML first.

Requirements

Tested with Node v11.2.0.

Install

npm install

Run

Important:

Make sure the output directory exists otherwise the script fails! For the examples in this README, run the command mkdir _data first.Sample content is in thecontent` directory in this repository.

Transform one Markdown file to JSON:

npm run start --sourceDir=content --outputDir=_data --inputFile=my-markdown-file.md --contentKey=contents --convertToHtml=true --escapeHtml=true

Transform all Markdown files in a directory recursively and aggregate JSON in one output file:

npm run start --aggregate=true --sourceDir=content --outputFile=data.json --outputDir=_data --contentKey=contents --convertToHtml=true --escapeHtml=true

Run options

  • sourceDir: String - directory with Markdown files
  • outputDir: String - output directory
  • inputFile: String - when cherry picking a single Markdown file to be transformed
  • outputFile: String - the resulting JSON file when walking an input directory with Markdown files
  • contentKey: String - the JSON key which holds the body text
  • convertToHtml: Boolean - if true, transforms Markdown to HTML
  • escapeHtml: Boolean - if true, escapes HTML

Tests

Run unit tests:

npm run test

Under the hood

Uses Remark plugins to transform Markdown and YAML in vFiles to JSON.

Current Tags

  • 2.0.0                                ...           latest (9 months ago)

7 Versions

  • 2.0.0                                ...           9 months ago
  • 1.0.7                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |