bin, tests
This commit is contained in:
parent
902686c0e2
commit
457adda267
4
LICENSE
4
LICENSE
@ -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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
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
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
18
README.md
18
README.md
@ -18,17 +18,23 @@ marked lingers around 350 lines long and still implements all markdown features.
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
$ npm install marked
|
``` bash
|
||||||
|
$ npm install marked
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
var marked = require('marked');
|
``` js
|
||||||
console.log(marked('i am using __markdown__.'));
|
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.
|
You also have direct access to the lexer and parser if you so desire.
|
||||||
|
|
||||||
var tokens = md.lexer(str);
|
``` js
|
||||||
console.log(md.parser(tokens));
|
var tokens = marked.lexer(str);
|
||||||
|
console.log(marked.parser(tokens));
|
||||||
|
```
|
||||||
|
|
||||||
## Todo (& notes to self)
|
## Todo (& notes to self)
|
||||||
|
|
||||||
@ -53,4 +59,4 @@ There may also be some bugs.
|
|||||||
- Handle escaping of HTML entities better.
|
- Handle escaping of HTML entities better.
|
||||||
- Client-side compatibility.
|
- 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.
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"author": "Christopher Jeffrey",
|
"author": "Christopher Jeffrey",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"main": "./lib/marked.js",
|
"main": "./lib/marked.js",
|
||||||
|
"bin": { "marked": "./bin/marked" },
|
||||||
"repository": "git://github.com/chjj/marked.git",
|
"repository": "git://github.com/chjj/marked.git",
|
||||||
"keywords": [ "markdown", "markup" ]
|
"keywords": [ "markdown", "markup" ]
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ var benchmark = function(func, t) {
|
|||||||
console.log('%s: %sms', func.name, new Date() - start);
|
console.log('%s: %sms', func.name, new Date() - start);
|
||||||
};
|
};
|
||||||
|
|
||||||
var md_ = require('../');
|
var marked_ = require('../');
|
||||||
benchmark(function md() {
|
benchmark(function marked() {
|
||||||
md_(text);
|
marked_(text);
|
||||||
});
|
});
|
||||||
|
|
||||||
var showdown_ = require('showdown');
|
var showdown_ = require('showdown');
|
||||||
@ -21,4 +21,4 @@ benchmark(function showdown() {
|
|||||||
var markdown_ = require('markdown');
|
var markdown_ = require('markdown');
|
||||||
benchmark(function markdownjs() {
|
benchmark(function markdownjs() {
|
||||||
markdown_.toHTML(text);
|
markdown_.toHTML(text);
|
||||||
});
|
});
|
||||||
|
@ -8,14 +8,15 @@ var md = require('../')
|
|||||||
, text = fs.readFileSync(__dirname + '/in.md', 'utf8');
|
, text = fs.readFileSync(__dirname + '/in.md', 'utf8');
|
||||||
|
|
||||||
var a = md(text)
|
var a = md(text)
|
||||||
, b = fs.readFileSync(__dirname + '/out.md', 'utf8');
|
, b = fs.readFileSync(__dirname + '/out.html', 'utf8');
|
||||||
|
|
||||||
console.log(a);
|
console.log(a);
|
||||||
console.log('----------------------------------------------------------------');
|
console.log('----------------------------------------------------------------');
|
||||||
console.log(b);
|
console.log(b);
|
||||||
|
console.log('----------------------------------------------------------------');
|
||||||
|
|
||||||
a = a.replace(/\s+/g, '');
|
a = a.replace(/\s+/g, '');
|
||||||
b = b.replace(/\s+/g, '');
|
b = b.replace(/\s+/g, '');
|
||||||
|
|
||||||
assert.ok(a === b, 'Failed.');
|
assert.ok(a === b, 'Failed.');
|
||||||
console.log('Complete.');
|
console.log('Complete.');
|
||||||
|
13
test/out.md
13
test/out.md
@ -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>
|
|
Loading…
x
Reference in New Issue
Block a user