Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdown-json

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-json

Markdown to json has yaml support and converts your markdown files to json so you can use them as a static api.

  • 1.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

markdown-json npm Standard - JavaScript Style Guide Publish packages

Markdown to json has yaml support and converts your markdown files to json so you can use them as a static api.

Installation

npm install markdown-json

Command line usage:

markdown-json [OPTIONS] [ARGS]

Options:
  -c, --config [STRING]              settings file (Default is ./settings.json)
  -D, --display BOOLEAN              enable display mode
  -d, --dist [STRING]                output file directory (Default is ./dist/output.json)
  -i, --ignore STRING                ignore file pattern
  -o, --deterministicOrder BOOLEAN   enable deterministic output ordering
  -p, --filePattern [STRING]         file(s) directory (Default is **/*.md)
  -P, --port [NUMBER]                server port (Default is 3001)
  -S, --server BOOLEAN               enable server
  -s, --src [STRING]                 file(s) directory (Default is ./)
  -w, --cwd [STRING]                 work directory (Default is ./)
  -h, --help                         display help and usage details

Require module usage:

const markdownJson = require('markdown-json');

markdownJson(<settingsObj>) // => returns a Promise

Usage Example:


Settings example

Use a object with all settings or save as a json file

{
  "name": "markdown-json",
  "cwd": "./",
  "src": "example/content/",
  "filePattern": "**/*.md",
  "ignore": "*(icon|input)*",
  "dist": "example/output.json",
  "metadata": true,
  "server": true,
  "port": 3001,
  "deterministicOrder": false
}
Call through command line example:
markdown-json -c ~/app/my-app-settings.json
Call through require module example:
const markdownJson = require('markdown-json');
const settings = {
        name: 'markdown-json',
      	cwd: './',
      	src: 'example/content/',
        filePattern: '**/*.md',
        ignore: "*(icon|input)*",
        dist: 'example/output.json',
        metadata: true,
        server: false,
        port: 3001,
        deterministicOrder: false
      };

markdownJson(settings).then((data) => {
  console.log('data:', data);
}).catch((err) => {
  console.log('error:', err);
})

Files input

File example 1
---
section: Elements
title: icons
tags:
- icons
- base
---

# Icons

Our icons list still is empty :(
File example 2
---
section: Elements
title: buttons
device:
- desktop
- mobile
styles:
- https://lalao.com/styles/structure.min.css
- https://lalao.com/styles/app.min.css
---

Follow some application examples of buttons

Types
============

## Base

Base button layout sample:

<button type="button" class="buy-button btn btn-success">
  <span class="icon"></span>
  <span class="text">Button</span>
</button>

\~~~scss
.btn-primary {
  @include states(#1A75CE, #086B9C);
}
\~~~

\~~~html
<button type="button" class="buy-button btn btn-success">
  <span class="icon"></span>
  <span class="text">Button</span>
</button>
\~~~

Output:

{
  "app": {
    "config": "./settings.json",
    "cwd": "./",
    "src": "example/content/",
    "filePattern": "**/*.md",
    "dist": "example/output.json",
    "name": "markdown-json",
    "version": "0.0.1"
  },
  "data": [
    {
      "section": "Elements",
      "title": "buttons",
      "device": [
        "desktop",
        "mobile"
      ],
      "styles": [
        "https://lalao.com/styles/structure.min.css",
        "https://lalao.com/styles/app.min.css"
      ],
      "contents": "<p>Follow some application examples of buttons</p>\n<h1 id=\"types\">Types</h1>\n<h3 id=\"base\">Base</h3>\n<p>Base button layout sample:</p>\n<button type=\"button\" class=\"buy-button btn btn-success\">\n  <span class=\"icon\"></span>\n  <span class=\"text\">Button</span>\n</button>\n\n<pre><code class=\"lang-scss\">.btn-primary {\n  @include states(#1A75CE, #086B9C);\n}\n</code></pre>\n<pre><code class=\"lang-html\">&lt;button type=&quot;button&quot; class=&quot;buy-button btn btn-success&quot;&gt;\n  &lt;span class=&quot;icon&quot;&gt;&lt;/span&gt;\n  &lt;span class=&quot;text&quot;&gt;Button&lt;/span&gt;\n&lt;/button&gt;\n</code></pre>\n",
      "excerpt": "<p>Follow some application examples of buttons</p>",
      "id": "buttons",
      "meta": {
        "relativePath": "content/buttons.html",
        "createdAt": "2020-10-08T16:05:30.415Z",
        "lastModified": "2020-10-08T16:05:14.452Z",
        "size": 2095,
        "formattedSize": "2.0 KB"
      }
    },
    {
      "section": "Elements",
      "title": "icons",
      "tags": [
        "icons",
        "base"
      ],
      "contents": "<h1 id=\"icons\">Icons</h1>\n<p>Our icons list still is empty :(</p>\n",
      "excerpt": "<p>Our icons list still is empty :(</p>",
      "id": "icons",
      "meta": {
        "relativePath": "content/globals/js-utils.html",
        "createdAt": "2019-08-27T18:01:33.747Z",
        "lastModified": "2019-08-27T18:01:33.747Z",
        "size": 331,
        "formattedSize": "331 Bytes"
      }
    }
  ]
}

TODOS

  • Node api with promises
  • Unit tests
  • Run with http server
  • Add file metadata

Keywords

FAQs

Package last updated on 14 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc