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

md_metadata_parser

v1.0.2

Published

md metada parser, tree node model

Downloads

5

Readme

md_metadata_parser NPM version Build Status Dependency Status

md YAML metada parser

Motivation

md_metadata_parser insert YAML metadata as Markdown comment.

You can hide metadata to the render consumer, and use the same .md file to store data for later processing - consumption.

md_metadata_parser can parse from md to json and vice versa.

Table of contents

Table of contents generated with markdown-toc

Installation

$ npm install --save md_metadata_parser

Usage

const mdMetadataParser = require('md_metadata_parser');

var mdData = fs.readFileSync("md_path.md", "utf8");

// parse the md file to json object
var resultTree = mdMetadataParser.parseMd2Json({ mdData });

// parse the json object to md
var outputMD = mdMetadataParser.parseJson2Md({ rootNode: resultTree });

Example

See https://github.com/balmacefa/md_metadata_parser/blob/main/test/index.test.js

API

parseMd2Json({'mdData', ...});

parse the md data to json format

| Option | Default value | Description | | ------ | ------------- | ----------- | | mdData | null | The md data to be parse | | startFormatNode | <!-- __NODE_START__ --> | Open node tag | endFormatNode | <!-- __NODE_END__ --> | Close node tag | startFormatMetadata | <!-- __meta_start__ | Open metadata tag | endFormatMetadata | __meta_end__ --> | Close metadata tag | startFormatContent | <!-- __content_start__ --> | Open content tag | endFormatContent | <!-- __content_end__ --> | Close content tag | startFormatChildren | <!-- __children_start__ --> | Open children tag | endFormatChildren | <!-- __children_end__ --> | Close children tag

parseJson2Md({'json', ...});

parse the md data to json format

| Option | Default value | Description | | ------ | ------------- | ----------- | | json | null | (JSON object) The json data to be parse | | startFormatNode | <!-- __NODE_START__ --> | Open node tag | endFormatNode | <!-- __NODE_END__ --> | Close node tag | startFormatMetadata | <!-- __meta_start__ | Open metadata tag | endFormatMetadata | __meta_end__ --> | Close metadata tag | startFormatContent | <!-- __content_start__ --> | Open content tag | endFormatContent | <!-- __content_end__ --> | Close content tag | startFormatChildren | <!-- __children_start__ --> | Open children tag | endFormatChildren | <!-- __children_end__ --> | Close children tag

Structure

There are 4 tags for describe the data Structure

1. Node tag

md: <!-- __NODE_START__ -->

This will be the json object container, all the others tags have to be inside,

Everything outside will be ignored.

md: <!-- __NODE_END__ -->

2. Metadata tag

md: <!-- __meta_start__

This will be parse as YAML

YAML.parse( content_inside_this_tag )

json attribute: "metadata"

__meta_end__ -->

3. Content tag

md: <!-- __content_start__ -->

This the render md content

json attribute: "content"

md: <!-- __content_end__ -->

4. Children tag

md: <!-- __children_start__ -->

Array of Node tag ( recursive )

json attribute: "children"

md: <!-- __children_end__ -->

Structure example

md

<!-- __NODE_START__  -->
<!-- __meta_start__
id: 1
description: 1111
date: 2020-12-23T22:38:58.000Z

__meta_end__ -->

<!-- __content_start__ -->
# Content 1
Content 1
<!-- __content_end__ -->

<!-- __children_start__ -->

      <!-- __NODE_START__  -->
      <!-- __meta_start__
      id: 01a
      description: 1a
      
      __meta_end__ -->
      <!-- __content_start__ -->
      Content 1a
      <!-- __content_end__ -->
      
      <!-- __NODE_END__  -->

<!-- __children_end__ -->

<!-- __NODE_END__  -->


<!-- __NODE_START__  -->
<!-- __meta_start__
id: 2
description: 2222

__meta_end__ -->

<!-- __content_start__ -->
## Content 2
Content 2
<!-- __content_end__ -->

<!-- __NODE_END__  -->

json

(parsed from md👆)

[
  {
    "metadata": {
      "id": 1,
      "description": 1111,
    },
    "content": "# Content 1\nContent 1",
    "children": [
      {
        "metadata": { "id": "01a", "description": "1a" },
        "content": "Content 1a"
      }
    ]
  },
  {
    "metadata": { "id": 2, "description": 2222 },
    "content": "## Content 2\nContent 2"
  },
]

License

MIT © balmacefa