0.88.0 • Published 11 years ago

wxi-flavored-markdown v0.88.0

Weekly downloads
32
License
-
Repository
github
Last release
11 years ago
 __      __   __   __   ______   ____                
/\ \  __/\ \ /\ \ /\ \ /\__  _\ /\  _`\   /'\_/`\    
\ \ \/\ \ \ \\ `\`\/'/'\/_/\ \/ \ \ \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

The WXI Flavor:

As of v0.6 it adds:

Meta Tags:

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 @@@ ... @@@.

Examples
One Line
@@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.
Multi Line
@@@
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.

Installation

To install automatically:

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

Manual installation from reposotory:

Clone reposotory:

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

Usage

Example

# 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]);
t = 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.meta, null, "    "
# render the text as html
rendered = t.render()
# view rendered output in console
console.log rendered

Output would be:

{
    "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.

Options

  • 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

Standards - Currently this means nothing skip this section

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

  • version
  • tags
  • description
  • author

Validation

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.

Meta Name Validations

  • If the name is uppercase it will be converted into all lowercase. This is hardcoded.

Meta Value Validations

Version
  • 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.
0.88.0

11 years ago

0.87.1

11 years ago

0.87.0

11 years ago

0.86.0

11 years ago

0.85.0

11 years ago

0.84.0

11 years ago

0.6.0

11 years ago