@phenomic/markdown-as-json

1.0.0 • Public • Published

@phenomic/markdown-as-json

Repo on GitHub Repo on GitLab

Transform markdown content as a JSON

Handles:

  • front-matter (via gray-matter)
  • auto slug for headings (with anchors)
  • code highlight (via highlight.js)
  • table of contents (via remark-toc)

The idea is to get a markdown like this

---
test: a
test2: b
---

## Test

[link](href)

```js
console.log(window);
```

like

{
  "test": "a",
  "test2": "b",
  "headings": [
    {
      "id": "test",
      "level": 2,
      "text": "Test",
    },
  ],
  "body": {
    "c": [
      {
        "c": [
          {
            "c": [
              {
                "p": {
                  "class": "icon icon-link",
                },
                "t": "span",
              },
            ],
            "p": {
              "aria-hidden": "true",
              "href": "#test",
            },
            "t": "a",
          },
          "Test",
        ],
        "p": {
          "id": "test",
        },
        "t": "h2",
      },
      "
",
      {
        "c": [
          {
            "c": [
              "link",
            ],
            "p": {
              "href": "href",
            },
            "t": "a",
          },
        ],
        "t": "p",
      },
      "
",
      {
        "c": [
          {
            "c": [
              {
                "c": [
                  "console",
                ],
                "p": {
                  "class": "hljs-built_in",
                },
                "t": "span",
              },
              ".log(",
              {
                "c": [
                  "window",
                ],
                "p": {
                  "class": "hljs-built_in",
                },
                "t": "span",
              },
              ")",
            ],
            "p": {
              "class": "hljs language-js",
            },
            "t": "code",
          },
        ],
        "t": "pre",
      },
    ],
    "t": "div",
  },
}

For easy rendering to dom (eg: React etc).

Check out input & output to get an idea of what to expect from this package.

LICENSE

Package Sidebar

Install

npm i @phenomic/markdown-as-json

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

33.2 kB

Total Files

23

Last publish

Collaborators

  • moox
  • bloodyowl