wxi-flavored-markdown

A markdown parser with a little bit of WeaponXI flavor

 __      __   __   __   ______   ____                
/\ \  __/\ \ /\ \ /\ \ /\__  _\ /\  _`\   /'\_/`\    
\ \ \/\ \ \ \\ `\`\/'/'\/_/\ \/ \ \ \L\_\/\      \   
 \ \ \ \ \ \ \`\/ > <     \ \ \  \ \  _\/\ \ \__\ \  
  \ \ \_/ \_\ \  \/'/\`\   \_\ \__\ \ \/  \ \ \_/\ \ 
   \ `\___x___/  /\_\\ \_\ /\_____\\ \_\   \ \_\\ \_\
    '\/__//__/   \/_/ \/_/ \/_____/ \/_/    \/_/ \/_/

WXI Flavored Markdown

This is a package that adds a couple new features to markdown without tinkering with other markdown flavors such as GitHub Flavored Markdown (GFM) or the default markdown parser.

This is a npm package that extends marked package, a markdown parser library, by chjj@github

As of v0.6 it adds:

Use if you want to add information about the file. Meta name (such as author or version) will be converted to lowercase so don't worry about matching the standarts' case. You can add one line metas with @@name: value or multiline metas by surrounding with @@@ ... @@@.

@@Author: Logan Howlett
@@VErSiOn: 0.6    <- This is the same 
@@version: 0.7    <- As this
@@VeRSION: 0.8    <- Or this, or "version" and "VERSION"
Duis autem vel eum iriure dolor in hendrerit 
in vulputate velit esse molestie consequat, 
vel illum dolore eu feugiat nulla facilisis.
@@@
description:Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Phasellus vel sapien quis leo volutpat viverra. 
Pellentesque tempor tortor sagittis diam volutpat facilisis. 
Aenean eleifend tristique.
@@@
@@@
description2:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Phasellus vel sapien quis leo volutpat viverra. 
Pellentesque tempor tortor sagittis diam volutpat facilisis. 
Aenean eleifend tristique.
@@@
@@@description3
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Phasellus vel sapien quis leo volutpat viverra. 
Pellentesque tempor tortor sagittis diam volutpat facilisis. 
Aenean eleifend tristique.
@@@
 
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Soon it will be a node package, until then use manual installation. However when the package is published WXIFM can be installed by this command:

$``npm install wxifm

Or if you want to install the package and automatically save dependency to your package.json

$``npm install wxifm --save

Clone reposotory:

$``git clone git@github.com:aponxi/npm-wxi-flavored-markdown.git

# require module 
wxi_flavor = require ('wxifm')
 
# let the text be some file 
fs = require 'fs'
text = fs.readFileSync('test.md','utf8')
 
# Parse the text by 
# new wxi_flavor (String text[, Object options]); 
= new wxi_flavor text{validate: on}
# meta information is stored in wxi_flavor.meta 
# lets view the meta information (prettyfied) that has been parsed in console. 
console.log JSON.stringify t.metanull"    "
# render the text as html 
rendered = t.render()
# view rendered output in console 
console.log rendered
{
    "author": [
        "nox"
    ],
    "homepage": [
        "www.weaponxi.com"
    ],
    "tags": {
        "markdown": null,
        "github": null,
        "repetitivetag": null,
        "tagwithsubtags": [
            "subtag"
        ],
        "another": [
            "subtag",
            "subtag2",
            "repeating",
            "this",
            "repeating"
        ]
    },
    "version": "1.0.2",
    "status": [
        "stable"
    ],
    "url": [
        "http://www.something.com"
    ],
    "description3": [
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. \nPhasellus vel sapien quis leo volutpat viverra. \nPellentesque tempor tortor sagittis diam volutpat facilisis. \nAenean eleifend tristique."
    ],
    "description1": [
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. \nPhasellus vel sapien quis leo volutpat viverra. \nPellentesque tempor tortor sagittis diam volutpat facilisis. \nAenean eleifend tristique."
    ],
    "description2": [
        "\nLorem ipsum dolor sit amet, consectetur adipiscing elit. \nPhasellus vel sapien quis leo volutpat viverra. \nPellentesque tempor tortor sagittis diam volutpat facilisis. \nAenean eleifend tristique."
    ]
}

And it outputs the rendered text.

  • validate (boolean):
    • on: Turns on validation
    • off: Turns off validation
  • ignore_invalid (boolean):
    • on : Don't return invalid metas but return others
    • off : All must be valid to return results
  • cover_tracks (boolean):
    • on : Remove metas found before rendering markdown
    • off: Setting off

Following are the guidlines to what is being processed as standard meta names:

  • version
  • tags
  • description
  • author

Right now there are several manipulations to the gathered data, and I tend to keep them customizable. As we are in Beta development Validations are hardcoded and will be available for customization in near future.

  • If the name is uppercase it will be converted into all lowercase. This is hardcoded.
  • When there is a "v" in front of the version number such as v1.0 we will parse it into 1.0
  • When there are multiple versions defined, we only get the first one.