From 0e2ce6b638840310cbb628714a88b773a6e7511b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 6 Apr 2012 02:56:12 -0500 Subject: [PATCH] touch up readme and man page --- README.md | 28 +++++++++++++--------------- man/marked.1 | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1bc6af1e..ecc718d3 100644 --- a/README.md +++ b/README.md @@ -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,7 +66,7 @@ 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. @@ -76,7 +74,7 @@ None of the above are mutually exclusive/inclusive. ## Usage ``` js -// set default options +// Set default options marked.setOptions({ gfm: true, pedantic: false, @@ -88,7 +86,7 @@ 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)); ``` @@ -96,7 +94,8 @@ console.log(marked.parser(tokens)); $ 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; diff --git a/man/marked.1 b/man/marked.1 index f7ec9b50..672e336e 100644 --- a/man/marked.1 +++ b/man/marked.1 @@ -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.