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

@g2view/markmap-lib

v0.0.1

Published

Visualize your Markdown as mindmaps with Markmap

Downloads

2

Readme

Clone this repo

Then build and run:

  • npm install
  • npm run-script build
  • node bin/cli.js mytest.md

To run it:

  npm install markmap-lib2
  npx markmap-lib2 note.md

markmap-lib

NPM License Downloads

Visualize your Markdown as mindmaps.

This project is heavily inspired by Markmap.

See online demo.

Usage

Command-line

Installation

Install globally:

$ yarn global add markmap-lib
# or
$ npm install markmap-lib -g

or use with npx:

$ npx markmap-lib

Commands

Usage: markmap [options] <input>

Create a markmap from a Markdown input file

Options:
  -V, --version          output the version number
  -o, --output <output>  specify filename of the output HTML
  --enable-mathjax       enable MathJax support
  --no-open              do not open the output file after generation
  -h, --help             display help for command

Suppose you have a Markdown file named note.md.

Run the following command to get an interactive mindmap:

$ markmap note.md

# without global installation
$ npx markmap-lib note.md

Then you will get a note.html in the same directory, and hopefully it will be open in your default browser.

MathJax

To enable MathJax support for your Markdown, pass --enable-mathjax:

$ markmap --enable-mathjax note.md

API

Installation

$ yarn add markmap-lib
# or
$ npm install markmap-lib

Transform

Transform Markdown to markmap data:

import { transform } from 'markmap-lib/dist/transform.common';

const data = transform(markdown);

Now we get the data for rendering in data.

Render

Render a markmap from transformed data:

Create an SVG element with explicit width and height:

<svg id="markmap" style="width: 800px; height: 800px"></svg>

Render a markmap to the SVG element:

import { markmap } from 'markmap-lib/dist/view.common';

markmap('#markmap', data);

// or pass an SVG element directly
const svgEl = document.querySelector('#markmap');
markmap(svgEl, data);

MathJax

To enable MathJax, you need to load MathJax before rendering markmap:

<script>
window.MathJax = {
  options: {
    skipHtmlTags: {
      '[-]': ['code', 'pre']
    }
  }
};
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>

and process Html with MathJax in options.processHtml:

import { markmap } from 'markmap-lib/dist/view.common';

markmap('#markmap', data, {
  processHtml: nodes => {
    if (window.MathJax.typeset) MathJax.typeset(nodes);
  },
});

Note:

  • The skipHtmlTags option is required because inline code generated from Markdown is always wrapped in <code>, which is ignored by MathJax by default.
  • The MathJax library should better be loaded synchronously so that we can just use it in options.processHtml without a flash.

Related