npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

org-file-parser-with-js

v0.1.58

Published

A parser for Emacs Org mode files.

Downloads

43

Readme

LIVE DEMO: https://cheng92.com/demo/org

CHANGELOG

2022-07-19

Bugs

2022-06-30

Bugs

  • block can't be parsed correctly without attribute, #0edc204

TODOs

  • [x] Header, * header

    • [x] Tags, * header1 :tag1:tag2:

    • [x] Properties

      • [x] CLOSED|DEADLINE -> OrgTimestamp

      • [x] CLOCK -> OrgClockValue -> { start, end?, duration? }

        :LOGBOOK:
        CLOCK: [2022-08-05 Fri 17:38]--[2022-08-05 Fri 17:39] =>  0:01
        :END:
              
        // => result
              
        {
        	name: 'CLOCK',
          value: { 
            start: { year: '2022', month: '08', day: '05', week: 'Fri', time: '17:38' }
            end: { year: '2022', month: '08', day: '05', week: 'Fri', time: '17:38' }, 
            duration: '0:01'
          },
          category: 'LOGBOOK'
        }
    • [x] parse header title as text, use parseText()

      * TODO header1 :tag1:tag2 =>

      {
        type: NodeTypes.HEADER,
        content: {
          type: NodeTypes.TEXT,
          children: [
            { type: NodeTypes.STATE, content: 'TODO' }
            { type: NodeTypes.TEXT, content: 'header1' }
          ]
        },
      	tags: ['tag1', 'tag2']
      }
  • [x] Text

    • [x] Colorful text, <red:text1 text2> or red:text1text2

      Without <>, only support simple syntax,if want to use complex colorful text, use <...> instead.

      • [x] Support emphasis text, `<red:text1 text2>
    • [x] Nested emphasis node

      _underline before <red:colorfultext> after_

      Support: _u1 <red:underline /italic/ c2> u2_

      Not support: _u1 <red:underline /it<red:a>lic/ c2> u2_

    • [ ] Special text, doc:documentation

    • [x] Self-define Emphasis, ~~, ==, ++, __, //, $$

      • [x] extra : !!, !@, !%, !&, @!, @@, @%, @&, %!, %@, %%, %&, &!, &@, &%, &&
    • [x] Badge text <badge:left|/|right>

      Full badge format: <badge:label | labelColor | message | color | / | logo | logoColor | / | messageLink | labelLink>

  • [x] Attribute, #+title: org-file-parser-with-js

  • [x] Timestamps

    • [x] Inactive timestamp: [yyyy-MM-dd Week hh:mm]

    • [x] Active timestamp: <yyyy-MM-dd Week hh:mm>

  • [x] Images

  • [x] Subscripts and Superscripts

    • [x] more richable text, eg. Emphasis, Colorful text
  • [x] List

    • [x] Unordered lists, -, +, *
    • [x] Ordered lists, 1. 1)
    • [x] List children parsing
  • [x] Blocks, #+begin_xxx ... #end_xxx

    • [x] Textblock, special text block

    • [x] block attributes, :result both :noweb yes

      // :result both :noweb yes =>
      [
        { name: 'result', value: 'both' },
        { name: 'noweb', value: 'yes' }
      ]
    • [x] block options, -n 20 -r

      // -n 20 -r =>
      [
        { name: 'n', value: '20' },
        { name: 'r', value: '' }
      ]
  • [ ] Links, [[link][desc]], [[link]], <<inner-link>>

    • [x] External link [[url][desc]]

      Support link types: fileattachmentbbdbdocviewdoignuselispgnusrmailmhehelphttphttpsidinfoircmailtonewsshell,etc.

      more details to -> https://orgmode.org/manual/External-Links.html

    • [x] Inner link, <<inner-link>>

      It is an inner link meta. Eg.

      1. one item
      2. <<target>>another item
      Here we refer to item [[target]].

      So, inner link(<<target>>) is related to a external link([[target]])

    • [ ] Triple argular brackets <<<radio link>>>

    • [x] Link Abbreviations

      This will only support #+LINK: abrrev https://...., do not support Emacs Lisp variables.

  • [x] TODO, DONE, etc. keywords

  • [x] Table

    • [x] Base table

      | name | value |
      |------+-------|
      | xxx  | yyy   |

      result:

      {
          "type": 12, // OrgNodeTypes.TABLE
          "nodes": [ // table rows
              {
                  "0": "xx",
                  "1": "yy"
              },
              {
                  "0": "al",
                  "1": "bb"
              }
          ],
          "columns": [ // table column properties
              {
                  "label": "name",
                  "prop": "0"
              },
              {
                  "label": "value",
                  "prop": "1"
              }
          ],
          "rows": 4,
          "indent": 0
      }

Usage

Installation:

$ npm install -D org-file-parser-with-js

Code:

const { baseParse } = rquire('org-file-parser-with-js')
// or import { baseParse } from 'org-file-parser-with-js'

const json = baseParse(`...org file content`)

// Result Example:

Example(demo.org)

#+title: test
#+author: gcclll
#+email: [email protected]


I'am test test!!!!

* header1-1 :test:bbb:ccc:
header1 content

** header2-1

Header2-1 content 1

#+test: header2 attribute

Header2-1 content 2

Header2-1 content 3

* emphasis node

Result Example JSON:

{
    "type": 0,
    "children": [
        {
            "type": 2,
            "name": "title",
            "value": "test"
        },
        {
            "type": 2,
            "name": "author",
            "value": "gcclll"
        },
        {
            "type": 2,
            "name": "email",
            "value": "[email protected]"
        },
        {
            "type": 1,
            "content": "I'am test test!!!!",
            "indent": 0,
            "children": [
                {
                    "type": 1,
                    "content": "I'am test test!!!!",
                    "indent": 0,
                    "children": []
                }
            ]
        },
        {
            "type": 3,
            "title": {
                "type": 1,
                "content": "header1-1",
                "indent": 0,
                "children": [
                    {
                        "type": 1,
                        "content": "header1-1",
                        "indent": 0,
                        "children": []
                    }
                ]
            },
            "indent": 0,
            "level": 1,
            "properties": [],
            "tags": [
                "test",
                "bbb",
                "ccc"
            ]
        },
        {
            "type": 1,
            "content": "header1 content",
            "indent": 0,
            "children": [
                {
                    "type": 1,
                    "content": "header1 content",
                    "indent": 0,
                    "children": []
                }
            ]
        },
        {
            "type": 3,
            "title": {
                "type": 1,
                "content": "header2-1",
                "indent": 0,
                "children": [
                    {
                        "type": 1,
                        "content": "header2-1",
                        "indent": 0,
                        "children": []
                    }
                ]
            },
            "indent": 0,
            "level": 2,
            "properties": [],
            "tags": []
        },
        {
            "type": 1,
            "content": "Header2-1 content 1",
            "indent": 0,
            "children": [
                {
                    "type": 1,
                    "content": "Header2-1 content 1",
                    "indent": 0,
                    "children": []
                }
            ]
        },
        {
            "type": 2,
            "name": "test",
            "value": "header2 attribute"
        },
        {
            "type": 1,
            "content": "Header2-1 content 2",
            "indent": 0,
            "children": [
                {
                    "type": 1,
                    "content": "Header2-1 content 2",
                    "indent": 0,
                    "children": []
                }
            ]
        },
        {
            "type": 1,
            "content": "Header2-1 content 3",
            "indent": 0,
            "children": [
                {
                    "type": 1,
                    "content": "Header2-1 content 3",
                    "indent": 0,
                    "children": []
                }
            ]
        },
        {
            "type": 3,
            "title": {
                "type": 1,
                "content": "emphasis node",
                "indent": 0,
                "children": [
                    {
                        "type": 1,
                        "content": "emphasis node",
                        "indent": 0,
                        "children": []
                    }
                ]
            },
            "indent": 0,
            "level": 1,
            "properties": [],
            "tags": []
        }
    ],
    "properties": [],
    "footnotes": [],
    "options": {}
}

Problems

  • : { type: 'div', props: { id: 'foo', children: [ [Object] ] } } will be parsed to
{
    "type": 0,
    "children": [
        {
            "type": 1,
            "content": ":{ type: 'div', props: { id: 'foo', children: [ [Object] ] } }",
            "indent": 0,
            "children": [
                {
                    "type": 1,
                    "content": ":{ type: 'div', props: { id: 'foo', children: "
                },
                {
                    "type": 1,
                    "content": "[",
                    "children": []
                },
                {
                    "type": 5, // should be 1 /*TEXT*/ and content -> `Object`
                    "sign": "[",
                    "children": [
                        {
                            "type": 1,
                            "content": "Object] ] } }   "
                        }
                    ],
                    "extra": false
                }
            ]
        }
    ],
    "properties": [],
    "footnotes": []
}