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

markdown-habr

v0.0.8

Published

Parse github flavored markdown as habrahabr xml markup

Downloads

2

Readme

markdown-habr

Package in npm | Github repo

Habrahabr is a russian social network / collective blog dedicated to IT and Computer Science. For its articles the social network is using a markup which has some HTML tags (with limited functionality) as well as some tags introduced by the site.

Markdown-habr is a simple tool to compile markdown to habrahabr HTML. It is represented by the library and the commandline tool to parse MD files. I wrote the tool mostly for myself because for me it is easier to write articles using markdown. So don't be surprised by its illogics.

Also Github-flavored markdown is supported.

For some features like image alignment and <br clear/> it might be a better idea to use the html/xml itself without santitizing. Also some features are expected to be buggy, too.

Usage as command line tool

In order to use it you have to have node.js and npm installed and all required variables added to your PATH system variable.

npm install -g markdown-habr
mdhabr example.md example.html

There are command-line parameters that affect some options of the parser.

  • -z, --sanitize strip HTML tags from source
  • -a, --no-anchors disable anchors creation
  • -l, --no-links disable anchor link generation around Header tags
  • -u, --no-slugs instead of using slugs generated from header text, for anchor links use 'h-[number]' format
  • -g, --no-gfm disable github-flavored markdown
  • -p, --pedantic conform to obscure parts of markdown.pl
  • -z, --sanitize strip HTML tags from input
  • -t, --no-smart-punctuation disable smart typograhic punctuation for things like quotes and dashes
  • -r, --use-p add paragraph tags to paragraphs (habrahabr does not use them)
  • -o, --remove-yo replace "ё" letter with "е"
  • -v, --version current library version
  • -h, --help this information
  • -d, --destination path to write result
  • -f, --source file to compile

Usage as library

The library utilizes marked markdown parser library with custom renderer plus some workarounds and ugly code parts to make it a bit more extensible.

var mdhabr = new require('markdown-habr')();
var result = mdhabr.parse("# Hello, I am a title \nAnd I am some text');

There are also options available. You can specify some or all of them to override defaults:

var mdhabr = require('markdown-habr');

var options = {
  // Add <anchor> tag before each heading with a slug
  add_anchors:      true,
  // Add <a href="#slug"> link to each heading. Only when add_anchors is enabled
  add_anchor_links: true,
  // Use title of article to generate a slug. Otherwise slugs will be h-1, h-2 etc.
  anchor_slugs:     true,
  // Pedantic feature of marked library. "Conform to obscure parts of markdown.pl"
  pedantic:         false,
  // "smart typograhic punctuation for things like quotes and dashes." of marked
  punctuation:      true,
  // Use github-flavored markdown
  gfm:              true,
  // Uses marked sanitize option to clean HTML tags from input
  sanitize:         false,
  // Replace Ё letter with Е
  remove_yo:        false,
  // Enable special tags (like habracut)
  enable_specials:  true
};

var result = mdhabr.parse("# Hello, I am a title \nAnd I am some text', options);

New syntax

Some new markdown tags/behaviors were implemented just for ease of habr articles writing.

Media links

Links to twitter, slideshare or youtube,rutube and vimeo videos, wrapped with square braces, will be turned into <twitter>, <slideshow> and <video> tags:

[https://twitter.com/GreatDismal/status/677760641105457153]
<twitter>https://twitter.com/GreatDismal/status/677760641105457153</twitter>

[http://www.slideshare.net/KyleDrake/bitcoin-the-cyberpunk-cryptocurrency]
<slideshow>http://www.slideshare.net/KyleDrake/bitcoin-the-cyberpunk-cryptocurrency</slideshow?

[https://www.youtube.com/watch?v=I3obFcCw8mk]
<video>https://www.youtube.com/watch?v=I3obFcCw8mk</video>

Note that the link url has to match my regex, which is pretty dumb.

Habracut

To make a <cut> tag, use this:

--x--

You also can use text or use more than two dashes and add spaces:

-- x ------------- Читать дальше

This should produce the <cut> tag:

<cut>
<cut text="Read More">

Code highlighting

Currently <source lang=" ... "></source> (with lang attribute) blocks are produced only when using github-flavored markdown fenced code blocks:

```JavaScript
console.log('Hello, world');
```

As for 19 Dec 2015 Habrahabr supports following highlighting models: Bash, C#, C++, CSS, Diff, HTML, XML, Ini, Java, JavaScript, PHP, Perl, Python, Ruby, SQL, 1C, AVR Assembler, ActionScript, Apache, Axapta, CMake, CoffeeScript, DOS, .bat, Delphi, Django, Erlang, Erlang REPL, Go, Haskell, Lisp, Lua, MEL, Markdown, Matlab, Nginx, Objective C, Parser3, Python profile, RenderMan, Rust, Scala, Smalltalk, TeX, VBScript, VHDL, Vala