mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-27 10:30:28 +00:00
65 lines
7.5 KiB
JSON
65 lines
7.5 KiB
JSON
|
{
|
|||
|
"name": "markdown",
|
|||
|
"version": "0.5.0",
|
|||
|
"description": "A sensible Markdown parser for javascript",
|
|||
|
"keywords": [
|
|||
|
"markdown",
|
|||
|
"text processing",
|
|||
|
"ast"
|
|||
|
],
|
|||
|
"maintainers": [
|
|||
|
{
|
|||
|
"name": "Dominic Baggott",
|
|||
|
"email": "dominic.baggott@gmail.com",
|
|||
|
"url": "http://evilstreak.co.uk"
|
|||
|
},
|
|||
|
{
|
|||
|
"name": "Ash Berlin",
|
|||
|
"email": "ash_markdownjs@firemirror.com",
|
|||
|
"url": "http://ashberlin.com"
|
|||
|
}
|
|||
|
],
|
|||
|
"contributors": [
|
|||
|
{
|
|||
|
"name": "Dominic Baggott",
|
|||
|
"email": "dominic.baggott@gmail.com",
|
|||
|
"url": "http://evilstreak.co.uk"
|
|||
|
},
|
|||
|
{
|
|||
|
"name": "Ash Berlin",
|
|||
|
"email": "ash_markdownjs@firemirror.com",
|
|||
|
"url": "http://ashberlin.com"
|
|||
|
}
|
|||
|
],
|
|||
|
"bugs": {
|
|||
|
"url": "http://github.com/evilstreak/markdown-js/issues"
|
|||
|
},
|
|||
|
"licenses": [
|
|||
|
{
|
|||
|
"type": "MIT",
|
|||
|
"url": "http://www.opensource.org/licenses/mit-license.php"
|
|||
|
}
|
|||
|
],
|
|||
|
"repository": {
|
|||
|
"type": "git",
|
|||
|
"url": "git://github.com/evilstreak/markdown-js.git"
|
|||
|
},
|
|||
|
"main": "./lib/index.js",
|
|||
|
"bin": {
|
|||
|
"md2html": "./bin/md2html.js"
|
|||
|
},
|
|||
|
"dependencies": {
|
|||
|
"nopt": "~2.1.1"
|
|||
|
},
|
|||
|
"devDependencies": {
|
|||
|
"tap": "~0.3.3"
|
|||
|
},
|
|||
|
"scripts": {
|
|||
|
"test": "tap ./test/*.t.js"
|
|||
|
},
|
|||
|
"readme": "# markdown-js\n\nYet another markdown parser, this time for JavaScript. There's a few\noptions that precede this project but they all treat markdown to HTML\nconversion as a single step process. You pass markdown in and get HTML\nout, end of story. We had some pretty particular views on how the\nprocess should actually look, which include:\n\n * producing well-formed HTML. This means that `em` and `strong` nesting\n is important, as is the ability to output as both HTML and XHTML\n\n * having an intermediate representation to allow processing of parsed\n data (we in fact have two, both [JsonML]: a markdown tree and an HTML tree)\n\n * being easily extensible to add new dialects without having to\n rewrite the entire parsing mechanics\n\n * having a good test suite. The only test suites we could find tested\n massive blocks of input, and passing depended on outputting the HTML\n with exactly the same whitespace as the original implementation\n\n[JsonML]: http://jsonml.org/ \"JSON Markup Language\"\n\n## Installation\n\nJust the `markdown` library:\n\n npm install markdown\n\nOptionally, install `md2html` into your path\n\n npm install -g markdown\n\n## Usage\n\n### Node\n\nThe simple way to use it with node is:\n\n```js\nvar markdown = require( \"markdown\" ).markdown;\nconsole.log( markdown.toHTML( \"Hello *World*!\" ) );\n```\n\n### Browser\n\nIt also works in a browser; here is a complete example:\n\n```html\n<!DOCTYPE html>\n<html>\n <body>\n <textarea id=\"text-input\" oninput=\"this.editor.update()\"\n rows=\"6\" cols=\"60\">Type **Markdown** here.</textarea>\n <div id=\"preview\"> </div>\n <script src=\"lib/markdown.js\"></script>\n <script>\n function Editor(input, preview) {\n this.update = function () {\n preview.innerHTML = markdown.toHTML(input.value);\n };\n input.editor = this;\n this.update();\n }\n var $ = function (id) { return document.getElementById(id); };\n new Editor($(\"text-input\"), $(\"preview\"));\n </script>\n </body>\n</html>\n```\n\n### Command line\n\nAssuming you've installed the `md2html` script (see Installation,\nabove), you can convert markdown to html:\n\n```bash\n# read from a file\nmd2html /path/to/doc.md > /path/to/doc.html\n\n# or from stdin\necho 'Hello *World*!' | md2html\n```\n\n### More options\n\nIf you want more control check out the documentation in\n[lib/markdown.js] which details all the methods and parameters\navailable (including examples!). One day we'll get the docs generated\nand hosted somewhere for nicer browsing.\n\n[lib/markdown.js]: http://github.com/evilstreak/markdown-js/blob/master/lib/markdown.js\n\nMeanwhile, here's an example of using the multi-step processing to\nmake wiki-style linking work by filling in missing link references:\n\n```js\nvar md = require( \"markdown\" ).markdown,\n text = \"[Markdown] is a simple text-based [markup language]\\n\" +\n \"created by [John Gruber]\\n\\n\" +\n \"[John Gruber]: http://daringfireball.net\";\n\n// parse the markdown into a tree and grab the link references\nvar tree = md.parse( text ),\n refs = tree[ 1 ].references;\n\n// iterate through the tree finding link references\n( function find_link_refs( jsonml ) {\n if ( jsonml[ 0 ] === \"link_ref\" ) {\n var ref = jsonml[ 1 ].ref;\n\n // if there's no reference, define a wiki link\n if ( !refs[ ref ] ) {\n refs[ ref ] = {\n href: \"http://en.wikipedia.org/wiki/\" + ref.replace(/\\s+/, \"_\" )\n };\n }\n }\n else if ( Array.isArray( jsonml[ 1 ] ) ) {\n jsonml[ 1 ].forEach( find_link_refs );\n }\n else if ( Array.isArray( jsonml[ 2 ] ) ) {\n jsonml[ 2 ].forEach( find_link_refs );\n }\n} )( tree );\n\n// convert the tree into html\nvar html = md.renderJsonML( md.toHTMLTree( tree ) );\nconsole.log( html );\n```\n\n## Intermediate Representation\n\nInternally the process to convert a chunk of markdown into a chunk of\nHTML has three steps:\n\n 1. Parse the markdown into a JsonML
|
|||
|
"readmeFilename": "README.markdown",
|
|||
|
"_id": "markdown@0.5.0",
|
|||
|
"_from": "markdown@"
|
|||
|
}
|