aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-15 22:02:27 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-15 22:02:27 -0800
commit9a1291b4d751d8533a56911d41b2596fa95eaf85 (patch)
treea1b755348d83cc7081c032acfa9dae3dacbff3ef
parent067cab4cdc5f4d2aa268adffb7d111c3a04e46f0 (diff)
Improved js README.md.
Still much to do.
-rw-r--r--js/README.md36
1 files changed, 32 insertions, 4 deletions
diff --git a/js/README.md b/js/README.md
index 9f1e043..6803754 100644
--- a/js/README.md
+++ b/js/README.md
@@ -5,20 +5,48 @@ CommonMark is a rationalized version of Markdown syntax,
with a [spec][the spec] and BSD3-licensed reference
implementations in C and JavaScript.
+ [the spec]: http://spec.commonmark.org
+
For more information, see <http://commonmark.org>.
To play with this library without installing it, see
the live dingus at <http://spec.commonmark.org/dingus.html>.
+Installing
+----------
+
+You can install the library using `npm`:
+
+ npm install commonmark
+
This package includes the commonmark library and a
command-line executable, `commonmark`.
-Basic usage example:
+For client-side use, you can do `make browserify` to produce
+a standalone JavaScript file `js/commonmark.js`,
+suitable for linking into a web page, or just fetch
+<http://spec.commonmark.org/js/commonmark.js>.
+
+Usage
+-----
+
+Instead of converting Markdown directly to HTML, as most converters
+do, `commonmark.js` parses Markdown to an AST (abstract syntax tree),
+and then renders this AST as HTML. This opens up the possibility of
+manipulating the AST between parsing and rendering. For example, one
+could transform all emphasis into ALL CAPS.
+
+Here's a basic usage example:
var reader = new commonmark.DocParser();
var writer = new commonmark.HtmlRenderer();
- var parsed = reader.parse("Hello *world*");
- var result = writer.render(parsed);
+ var parsed = reader.parse("Hello *world*"); // parsed is a 'Node' tree
+ var result = writer.render(parsed); // result is a string
+
+<!-- TODO
- [the spec]: http://spec.commonmark.org
+- example of tree manipulation
+- options
+- API documentation (each function)
+-->