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

markmon

v0.0.7

Published

A Markdown live previewer with fast Mathjax re-rendering

Downloads

18

Readme

markmon

markmon is a pandoc/markdown previewer with fast Mathjax re-rendering.

markmon

While this is built mainly for pandoc and Mathjax, it should also work for other markdown parsers in general. Though you should really check out pandoc if you haven't.

Also note that markmon does not contain a parser itself.

Features

  • Edit markdown in your favorite editor, get update in real-time as you save
  • Preview with anything connected to your network, including your mobile devices
  • Automatically highlight and scroll to the latest change as the content updates
  • Fast Mathjax re-rendering, no more loading messages!
  • Support for loading locally referenced assets like images

Install

npm install -g markmon

How to use?

Usage: node ./bin/markmon [filename] --port [num] --command [string] --view [string] --projectdir [path] --stylesheet [path] --help

Options:
  --port        Port to listen to                                                 [default: 3000]
  --command     Command to parse markdown to html                                 [default: "pandoc --mathjax -N -t HTML5"]
  --view        Command to execute after the server is setup                    
  --projectdir  Root directory of your project, useful for local image resources
  --stylesheet  Path to your custom stylesheet                                  
  --help        Get this help message    

This will set up a local server at localhost:[port], and you can access the generated html through your web browsers.

An example of --view for Mac OS X is --view "open \"http://localhost:3000\"" which opens the page right after the server is set up.

Note that & open "http://localhost:3000\" will not work since it takes some time to set up the server and parse the markdown document.

command must be able to read from stdin and output html to stdout.

Also the working directory of command will be set to the directory of the file, so commands like markmon --command "pandoc --mathjax -N -t HTML5 --bibliograph=references.bib", where references.bib is in the same directory as the file, will work.

You can also separately specify a project directory which will be used to override the working directory.

Moreover, the directory of the file is also added as the static directory of the server, so the locally referenced images will also be shown correctly.

Moreover, if no file name is specified, markmon will run in server mode: it will listen at the port for PUT requests of markdown documents and convert them into html with the command specified, then broadcast the final html snippet to all sockets. This can be useful for plugins etc.

How does it work?

It sets up a node.js server to watch the markdown file, and parses the file and sends out converted html segments via socket.io once there's an update.

The frontend then diff the current DOM tree and the new DOM tree and apply a series of insertions and deletions to update the DOM tree. Then it runs Mathjax render only on DOM nodes that are inserted. So in general the DOM update and Mathjax rendering should be fast.

The diff algorithm is an optimized and recursive version of the classic Levenshtein distance algorithm which runs in roughly Nd time, where N is the length of the document and d is the length of change in terms of the dom elements. So it is very fast for most cases, even if your document is large.

Issues

  • Only tested on Mac OS X 10.9. The file watcher may be problematic in some systems.

License

MIT

Acknowledgments

style/fabirc_plaid.png is obtained from http://subtlepatterns.com