0.0.16 • Published 10 years ago

better-markdown-walker v0.0.16

Weekly downloads
46
License
-
Repository
github
Last release
10 years ago

markdown-walker Build Status

Utility for walking a directory structure and parsing markdown files into html

#Getting Started

To install this package you simply run this from the command line:

npm install better-markdown-walker --save

This utility uses the process.cwd() as the root when it is passed a relative file path. You can override this by passing { cwd: "anyPath" } to any of the constructors.

##MarkdownFile

You can process files individually if you like. Let's say we would like to write a file my-markdown.md.

var mw = require("better-markdown-walker");
var markdownFile = new mw.MarkdownFile("./relative-path/my-markdown.md");
markdownFile.write("#anyMarkdownContent");

Ideally you would then load the file again using the parse method to get hold of the html and various other info.

var mw = require("better-markdown-walker");
var markdownFile = new mw.MarkdownFile("./relative-path/my-markdown.md");
var result = markdownFile.parse();

This would give you an object of the following shape:

{ fullPath: '/usr/local/src/nodejs/markdown-walker/relative-path/my-markdown.md',
  relativePath: './relative-path/my-markdown.md',
  markdown: '#anyMarkdownContent',
  html: '<h1 id="anymarkdowncontent">anyMarkdownContent</h1>' }

##MarkdownDirectory

You can also work with directories en masse if you need to by creating a MarkdownDirectory object. Let's say we would like to parse the same file above but instead we use a directory object. This would trawl through the root directory parsing out files that have a .md extension.

var mw = require("better-markdown-walker");
var markdownDirectory = new mw.MarkdownDirectory("./relative-path/");
var results = markdownDirectory.parse();

Instead of getting just one file it will find all of them. A naf example but the only difference in this case would be that you would get an array.

[{ fullPath: '/usr/local/src/nodejs/markdown-walker/relative-path/my-markdown.md',
  relativePath: './relative-path/my-markdown.md',
  markdown: '#anyMarkdownContent',
  html: '<h1 id="anymarkdowncontent">anyMarkdownContent</h1>' }]

There you have it folks. Watch this space for file system hooks, express middle and git integration :)

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago