1 | hammerdown
|
2 | ==========
|
3 |
|
4 | [![Build Status](https://travis-ci.org/tjchaplin/hammerdown.png?branch=master)](https://travis-ci.org/tjchaplin/hammerdown)
|
5 |
|
6 | Streaming markdown writer
|
7 |
|
8 | # Get Started
|
9 |
|
10 | ## Simple Example
|
11 |
|
12 | ```javascript
|
13 | var hammerdown = require("hammerdown");
|
14 |
|
15 | //Write markdown
|
16 | hammerDown.headerOpen(1)
|
17 | .text("A Markdown Header")
|
18 | .headerClose()
|
19 | .text("Some text ").boldOpen().text("bold text").blodClose()
|
20 | .done();
|
21 |
|
22 | hammerDown.readableStream().pipe(process.stdout);
|
23 |
|
24 | //Outputs
|
25 | // # A Markdown Header
|
26 | //
|
27 | // Some text **bold text**
|
28 | ```
|
29 |
|
30 | ## Github Flavored Markdown Example
|
31 |
|
32 | ```javascript
|
33 | var hammerdown = require("hammerdown").githubFlavoredHammerDown;
|
34 |
|
35 | //Write markdown
|
36 | hammerDown.blockCodeOpen()
|
37 | .codeOpen("javascript")
|
38 | .text("function myFunction(params){\n\treturn true;\n};\n")
|
39 | .codeClose()
|
40 | .blockCodeClose()
|
41 | .done();
|
42 |
|
43 | hammerDown.readableStream().pipe(process.stdout);
|
44 |
|
45 | //Outputs
|
46 | // ```javascript
|
47 | // function myFunction(params){
|
48 | // return true;
|
49 | // };
|
50 | // ```
|
51 | ```
|
52 |
|
53 | # Install
|
54 |
|
55 | ```
|
56 | npm install hammerdown
|
57 | ```
|
58 |
|
59 | # Purpose
|
60 |
|
61 | To have an easy way to programatically generate a stream of markdown text. This library includes a complete set of Markdown attributes to generate Markdown document streams. It also includes the definitions used to produce [Github-Flavored-Markdown](https://help.github.com/articles/github-flavored-markdown).
|
62 |
|
63 | Markdown is a mechanism to create documents. [See](http://daringfireball.net/projects/markdown/) for more details. Hammerdown allows developers to leverage the simplicity of Markdown for whatever purpose this say fit. This may include using hammerdown to convert text, XML, or HTML into Markdown.
|
64 |
|
65 | # Examples
|
66 |
|
67 | Below is a select group of examples. More examples can be found by looking at the integration tests.
|
68 |
|
69 | # Github Flavored Markdown Examples
|
70 |
|
71 | ## Tables
|
72 | ```javascript
|
73 | var hammerdown = require("hammerdown").githubFlavoredHammerDown;
|
74 |
|
75 | //Write markdown
|
76 | hammerDown.tableRowOpen()
|
77 | .tableHeaderOpen()
|
78 | .text("header1")
|
79 | .tableHeaderClose()
|
80 | .tableHeaderOpen()
|
81 | .text("header2")
|
82 | .tableHeaderClose()
|
83 | .tableRowClose()
|
84 | .tableRowOpen()
|
85 | .tableDataOpen()
|
86 | .text("row1-col1")
|
87 | .tableDataClose()
|
88 | .tableDataOpen()
|
89 | .text("row1-col2")
|
90 | .tableDataClose()
|
91 | .tableRowClose()
|
92 | .done();
|
93 |
|
94 | hammerDown.readableStream().pipe(process.stdout);
|
95 |
|
96 | //Outputs
|
97 | // |header1|header2|
|
98 | // |---|---|
|
99 | // |row1-col1|row1-col2|
|
100 | ```
|