bin, tests

This commit is contained in:
Christopher Jeffrey 2011-08-10 21:50:25 -05:00
parent 902686c0e2
commit 457adda267
6 changed files with 23 additions and 28 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2011, Christopher Jeffrey (http://epsilon-not.net/)
Copyright (c) 2011, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.

View File

@ -18,17 +18,23 @@ marked lingers around 350 lines long and still implements all markdown features.
## Install
$ npm install marked
``` bash
$ npm install marked
```
## Usage
var marked = require('marked');
console.log(marked('i am using __markdown__.'));
``` js
var marked = require('marked');
console.log(marked('i am using __markdown__.'));
```
You also have direct access to the lexer and parser if you so desire.
var tokens = md.lexer(str);
console.log(md.parser(tokens));
``` js
var tokens = marked.lexer(str);
console.log(marked.parser(tokens));
```
## Todo (& notes to self)
@ -53,4 +59,4 @@ There may also be some bugs.
- Handle escaping of HTML entities better.
- Client-side compatibility.
I've still just begun to write this. I expect I will be updating it frequently.
I've still just begun to write this. I expect I will be updating it frequently.

View File

@ -4,6 +4,7 @@
"author": "Christopher Jeffrey",
"version": "0.0.1",
"main": "./lib/marked.js",
"bin": { "marked": "./bin/marked" },
"repository": "git://github.com/chjj/marked.git",
"keywords": [ "markdown", "markup" ]
}
}

View File

@ -8,9 +8,9 @@ var benchmark = function(func, t) {
console.log('%s: %sms', func.name, new Date() - start);
};
var md_ = require('../');
benchmark(function md() {
md_(text);
var marked_ = require('../');
benchmark(function marked() {
marked_(text);
});
var showdown_ = require('showdown');
@ -21,4 +21,4 @@ benchmark(function showdown() {
var markdown_ = require('markdown');
benchmark(function markdownjs() {
markdown_.toHTML(text);
});
});

View File

@ -8,14 +8,15 @@ var md = require('../')
, text = fs.readFileSync(__dirname + '/in.md', 'utf8');
var a = md(text)
, b = fs.readFileSync(__dirname + '/out.md', 'utf8');
, b = fs.readFileSync(__dirname + '/out.html', 'utf8');
console.log(a);
console.log('----------------------------------------------------------------');
console.log(b);
console.log('----------------------------------------------------------------');
a = a.replace(/\s+/g, '');
b = b.replace(/\s+/g, '');
assert.ok(a === b, 'Failed.');
console.log('Complete.');
console.log('Complete.');

View File

@ -1,13 +0,0 @@
<h1>A heading</h1>
<p>Just a note, I've found that I can't test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They're also completely <a href="http://google.com/" title="Google">inconsistent</a> with regards to paragraphs in list items.</p>
<p>A link</p>
<aside>this will make me fail the test because
markdown.js doesnt acknowledge arbitrary html blocks =/</aside>
<ul><li>List Item 1</li><li>List Item 2 <ul><li>New List Item 1 Hi, this is a list item.</li><li>New List Item 2 Another item <pre><code>Code goes here.
Lots of it...</code></pre></li><li>New List Item 3 The last item</li></ul></li><li>List Item 3 The final item.</li></ul>
<blockquote><ul><li>bq Item 1</li><li>bq Item 2 <ul><li>New bq Item 1</li><li>New bq Item 2 Text here</li></ul></li></ul></blockquote>
<blockquote><p> Another blockquote To quoth someone and whatnot markdown.js breaks here again</p></blockquote>
<h2>Another Heading</h2>
<p>Hello <em>world</em>. Here is a <a href="//hello">link</a>. And an image <img src="src" alt="alt">.</p>
<pre><code>Code goes here.
Lots of it...</code></pre>