• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

scottstanfield/markdown-to-json:

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

scottstanfield/markdown-to-json

开源软件地址(OpenSource Url):

https://github.com/scottstanfield/markdown-to-json

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

markdown-to-json

Build Status

Tool for converting YAML Front Matter in Markdown files to JSON files.

m2j is used to read a folder of Markdown files, pulling out the YAML Front Matter from each, and saving it all as a JSON blob.

This is especially useful if you have a folder full of Markdown files that you want scanned and processed into a single JSON file, which can then be consumed by Angular on the client, cached in a Node server, or saved in a NoSQL database.

In addition to moving the YAML to JSON, a few extra elements are created:

  • iso8601 formatted timestamp from date using Moment.js
  • preview is the first 70 or so characters of the actual raw Markdown content, with ellipses at the end
  • basename is the filename without the path or extension
  • content is created only if the content flag is enabled; raw Markdown content will be unabridged

Example

% m2j --help

  Usage: m2j [options] <files>

  Options:

    -h, --help               output usage information
    -V, --version            output the version number
    -w --width <int>         max width of preview text [70]. Set to 0 for no preview.
    -p --pretty              format JSON with newlines
    -c --content             include the full content of the file unabridged
    -o --outfile <filename>  filename to save json to [output.json]


% m2j.js lottery.md

lottery.md

---
title: The Lottery Ticket
author: Anton C.
date: "2013-03-15 15:00"
template: article.jade
tags:
  - Fiction
  - Russian

---

Ivan Dmitritch, a middle-class man who lived with his family on an income of twelve hundred a year and was very well satisfied with his lot, sat down on the sofa after supper and began reading the newspaper. 

output

{
  "files": [
    {
      "title": "The Lottery Ticket",
      "author": "Anton C.",
      "date": "1893-04-01",
      "template": "article.jade",
      "tags": [
        "Fiction",
        "Russian"
      ],
      "preview": "Ivan Dmitritch, a middle-class man who lived with his family on an …",
      "iso8601Date": "1893-04-01T00:00:00-07:00",
      "basename": "lottery.md"
    }
  ]
}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap