Permalink
Browse files

touch up readme and man page

  • Loading branch information...
chjj committed Apr 6, 2012
1 parent 78b0c6e commit 0e2ce6b638840310cbb628714a88b773a6e7511b
Showing with 14 additions and 16 deletions.
  1. +13 −15 README.md
  2. +1 −1 man/marked.1
View
@@ -1,6 +1,6 @@
# marked
-A full-featured markdown parser and compiler.
+A full-featured markdown parser and compiler, written in javascript.
Built for speed.
## Benchmarks
@@ -34,15 +34,13 @@ For those feeling skeptical: These benchmarks run the entire markdown test suite
1000 times. The test suite tests every feature. It doesn't cater to specific
aspects.
-Benchmarks for other engines to come (?).
-
## Install
``` bash
$ npm install marked
```
-## Another javascript markdown parser
+## Another Javascript Markdown Parser
The point of marked was to create a markdown compiler where it was possible to
frequently parse huge chunks of markdown without having to worry about
@@ -68,15 +66,15 @@ marked has 3 different switches which change behavior.
- __pedantic__: Conform to obscure parts of `markdown.pl` as much as possible.
Don't fix any of the original markdown bugs or poor behavior.
-- __gfm__: Enabled github flavored markdown (default for backward compatibility).
+- __gfm__: Enable github flavored markdown (enabled by default).
- __sanitize__: Sanitize the output. Ignore any HTML that has been input.
None of the above are mutually exclusive/inclusive.
## Usage
``` js
-// set default options
+// Set default options
marked.setOptions({
gfm: true,
pedantic: false,
@@ -88,15 +86,16 @@ console.log(marked('i am using __markdown__.'));
You also have direct access to the lexer and parser if you so desire.
``` js
-var tokens = marked.lexer(str);
+var tokens = marked.lexer(text);
console.log(marked.parser(tokens));
```
``` bash
$ node
> require('marked').lexer('> i am using marked.')
[ { type: 'blockquote_start' },
- { type: 'text', text: ' i am using marked.' },
+ { type: 'paragraph',
+ text: 'i am using marked.' },
{ type: 'blockquote_end' },
links: {} ]
```
@@ -120,10 +119,10 @@ Example implementation:
``` js
var highlight = require('my-syntax-highlighter')
- , marked_ = require('marked');
+ , marked = require('marked');
-var marked = function(text) {
- var tokens = marked_.lexer(text)
+marked.highlight = function(text) {
+ var tokens = marked.lexer(text)
, l = tokens.length
, i = 0
, token;
@@ -132,14 +131,13 @@ var marked = function(text) {
token = tokens[i];
if (token.type === 'code') {
token.text = highlight(token.text, token.lang);
- // marked should not escape this
+ // Tell marked that this
+ // token is already escaped.
token.escaped = true;
}
}
- text = marked_.parser(tokens);
-
- return text;
+ return marked.parser(tokens);
};
module.exports = marked;
View
@@ -27,7 +27,7 @@ Conform to obscure parts of markdown.pl as much as possible. Don't fix original
markdown bugs.
.TP
.BI \-\-gfm
-Enabled github flavored markdown.
+Enable github flavored markdown.
.TP
.BI \-\-sanitize
Sanitize output. Ignore any HTML input.

0 comments on commit 0e2ce6b

Please sign in to comment.