Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 helpers
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Jakefile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 markdown.pegjs
Octocat-spinner-32 parser-defs.js
Octocat-spinner-32 test-mdown-parser-with-node.js
README.md

Markdown parser with PegJS

A Markdown parser written in JavaScript, generated with PEG grammar. Currently, in progress.

This is a component of xtd project, but I plan to finish developing it separately and then merge the result there. (So, the most part of its development history is located there).

In fact, it is a translation of PegC Markdown parser to JavaScript. But in the end, there are a lot differences in the sources and result.

The both C variant and JS (this) variant build a tree of parsed document elements, including their offsets and additional data required for generating some HTML result or hightlighting a syntax in some JavaScript implementation.

Sources

The Development State

Finished

  • Inlines: Strong, Em, Code
  • Html Blocks, Html entities
  • Headings
  • Horizontal Rules
  • Paragraphs
  • Top-level Lists
  • Top-level verbatims
  • Links, all modifications
  • Images, all modifications
  • Oh, all that stuff except complex lists

Not finished

(They were working some not ideal way, but I am currently refactoring this part)

So currently, the lists are parsed ok, but I plan to modify their rules to support complex indentations.

Which Way the Result Looks Like

When parsing a MarkDown document, you get a JavaScript Object containing the document tree in Markdown terms. I'll make a detailed description when I'll finish an implementation.

Competitors

Just a JS-ones:

To Develop

Install last node.js version (v0.5.8+)

Install npm

Run in node directory (or with -g):

npm install pegjs
npm install jake@1.7 # or higher

cd ~/Worktable # (for example)
git clone git@github.com:shamansir/pegjs.git
cd ./pegjs
jake build
node test/run
ln -sf ~/Worktable/pegjs <nodejs-location>/lib/node_modules
ln -s <nodejs-location>/lib/node_modules ./node_modules # optional, if pegjs module not found
cd ~/Workspace # (for example) 
git clone git@github.com:shamansir/mdown-parse-pegjs.git
cd ./mdown-parse-pegjs
node ./test-mdown-parser-with-node.js
Something went wrong with that request. Please try again.