Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 904 Bytes

README.md

File metadata and controls

59 lines (45 loc) · 904 Bytes

tana-to-json

This package provides a function to parse Tana Paste format to JSON.

Install:

npm install tana-to-json

Usage

import { tanaToJson } from "./src/index";

const tanaPaste = `
- Hello world #test
  - foo:: bar
  - a non-field child`;

const json = tanaToJson(tanaPaste);

The output of the above will be the following object:

[
  {
    "name": "Hello world #test",
    "tags": [
      "test"
    ],
    "type": "node",
    "children": [
      {
        "name": "foo",
        "type": "field",
        "children": [
          {
            "name": "bar",
            "type": "node"
          }
        ]
      },
      {
        "name": "a non-field child",
        
        "type": "node"
      }
    ]
  }
]

Acknowledgements

The code here was adapted from Brett Adam's great tana-helper suite of tools.