marked 0.3.16 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ root = true
2
+
3
+ [*.{json,js}]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ indent_style = space
8
+ indent_size = 2
9
+
10
+ [*.md, !test/*.md]
11
+ charset = utf-8
12
+ end_of_line = lf
13
+ insert_final_newline = true
14
+ trim_trailing_whitespace = true
15
+ indent_style = tab
16
+ indent_size = 4
package/.eslintignore ADDED
@@ -0,0 +1 @@
1
+ *.min.js
package/.eslintrc.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "extends": "standard",
3
+ "plugins": [
4
+ "standard"
5
+ ],
6
+ "parserOptions": { "ecmaVersion": 5 },
7
+ "rules": {
8
+ "semi": "off",
9
+ "indent": ["warn", 2, {
10
+ "VariableDeclarator": { "var": 2 },
11
+ "SwitchCase": 1,
12
+ "outerIIFEBody": 0
13
+ }],
14
+ "space-before-function-paren": "off",
15
+ "operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
16
+ "no-cond-assign": "off",
17
+ "no-useless-escape": "off",
18
+ "no-return-assign": "off",
19
+ "one-var": "off",
20
+ "no-control-regex": "off"
21
+ },
22
+ "env": {
23
+ "node": true,
24
+ "browser": true,
25
+ "amd": true,
26
+ "jasmine": true
27
+ }
28
+ }
package/.travis.yml CHANGED
@@ -1,5 +1,44 @@
1
1
  language: node_js
2
- node_js:
3
- - "0.10"
4
- - "0.8"
5
- - "0.6"
2
+
3
+ jobs:
4
+ fast_finish: true
5
+ allow_failures:
6
+ - stage: security scan 🔐
7
+
8
+ include:
9
+ - stage: unit tests 👩🏽‍💻
10
+ script: npm run test:unit
11
+ node_js: lts/*
12
+
13
+ - stage: spec tests 👩🏽‍💻
14
+ script: npm run test:specs
15
+ node_js: v0.10
16
+ - node_js: v4
17
+ - node_js: lts/*
18
+ - node_js: node
19
+
20
+ - stage: lint ✨
21
+ script: npm run test:lint
22
+ node_js: lts/*
23
+
24
+ - stage: minify 🗜️
25
+ script: |
26
+ npm run build
27
+ if ! git diff --quiet; then
28
+ git config --global user.email "travis@travis-ci.org"
29
+ git config --global user.name "Travis-CI"
30
+ git config credential.helper "store --file=.git/credentials"
31
+ echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
32
+ git commit -am '🗜️ minify [skip ci]'
33
+ git push origin HEAD:${TRAVIS_BRANCH}
34
+ fi
35
+ node_js: lts/*
36
+ if: branch = master AND type = push
37
+
38
+ - stage: security scan 🔐
39
+ script: npm run test:redos
40
+ node_js: lts/*
41
+
42
+ cache:
43
+ directories:
44
+ - node_modules
package/LICENSE.md ADDED
@@ -0,0 +1,43 @@
1
+ # License information
2
+
3
+ ## Contribution License Agreement
4
+
5
+ If you contribute code to this project, you are implicitly allowing your code
6
+ to be distributed under the MIT license. You are also implicitly verifying that
7
+ all code is your original work. `</legalese>`
8
+
9
+ ## Marked
10
+
11
+ Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in
21
+ all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
+ THE SOFTWARE.
30
+
31
+ ## Markdown
32
+
33
+ Copyright © 2004, John Gruber
34
+ http://daringfireball.net/
35
+ All rights reserved.
36
+
37
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
38
+
39
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
40
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
41
+ * Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
42
+
43
+ This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
package/README.md CHANGED
@@ -1,52 +1,47 @@
1
- # marked
1
+ <a href="https://marked.js.org">
2
+ <img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
3
+ </a>
2
4
 
3
- > A full-featured markdown parser and compiler, written in JavaScript. Built
4
- > for speed.
5
+ # Marked
5
6
 
6
- [![NPM version](https://badge.fury.io/js/marked.svg)][badge]
7
+ [![npm](https://img.shields.io/npm/v/marked.svg)](https://www.npmjs.com/package/marked)
8
+ [![gzip size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/marked@0.3.19/marked.min.js?compression=gzip)](https://cdn.jsdelivr.net/npm/marked@0.3.19/marked.min.js)
9
+ [![install size](https://packagephobia.now.sh/badge?p=marked@0.3.19)](https://packagephobia.now.sh/result?p=marked@0.3.19)
10
+ [![downloads](https://img.shields.io/npm/dt/marked.svg)](https://www.npmjs.com/package/marked)
11
+ [![travis](https://travis-ci.org/markedjs/marked.svg?branch=master)](https://travis-ci.org/markedjs/marked)
7
12
 
8
- ## Install
13
+ - ⚡ built for speed
14
+ - ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
15
+ - ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
16
+ - 🌐 works in a browser, on a server, or from a command line interface (CLI)
9
17
 
10
- ``` bash
11
- npm install marked --save
12
- ```
18
+ ## Demo
13
19
 
14
- or if you want to use the `marked` CLI tool (not necessary when using npm run-scripts):
20
+ Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
15
21
 
16
- ``` bash
17
- npm install -g marked
18
- ```
22
+ ## Docs
19
23
 
20
- ## Usage
24
+ Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
21
25
 
22
- Minimal usage:
26
+ ## Installation
23
27
 
24
- ```js
25
- var marked = require('marked');
26
- console.log(marked('I am using __markdown__.'));
27
- // Outputs: <p>I am using <strong>markdown</strong>.</p>
28
- ```
28
+ **CLI:** `npm install -g marked`
29
29
 
30
- Example setting options:
30
+ **In-browser:** `npm install marked --save`
31
31
 
32
- ```js
33
- var marked = require('marked');
34
- marked.setOptions({
35
- renderer: new marked.Renderer(),
36
- gfm: true,
37
- tables: true,
38
- breaks: false,
39
- pedantic: false,
40
- sanitize: false,
41
- smartLists: true,
42
- smartypants: false,
43
- xhtml: false
44
- });
32
+ ## Usage
45
33
 
46
- console.log(marked('I am using __markdown__.'));
34
+ **CLI**
35
+
36
+ ``` bash
37
+ $ marked -o hello.html
38
+ hello world
39
+ ^D
40
+ $ cat hello.html
41
+ <p>hello world</p>
47
42
  ```
48
43
 
49
- ### Browser
44
+ **Browser**
50
45
 
51
46
  ```html
52
47
  <!doctype html>
@@ -54,364 +49,19 @@ console.log(marked('I am using __markdown__.'));
54
49
  <head>
55
50
  <meta charset="utf-8"/>
56
51
  <title>Marked in the browser</title>
57
- <script src="lib/marked.js"></script>
58
52
  </head>
59
53
  <body>
60
54
  <div id="content"></div>
55
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
61
56
  <script>
62
57
  document.getElementById('content').innerHTML =
63
- marked('# Marked in browser\n\nRendered by **marked**.');
58
+ marked('# Marked in the browser\n\nRendered by **marked**.');
64
59
  </script>
65
60
  </body>
66
61
  </html>
67
62
  ```
68
63
 
69
- ## marked(markdownString [,options] [,callback])
70
-
71
- ### markdownString
72
-
73
- Type: `string`
74
-
75
- String of markdown source to be compiled.
76
-
77
- ### options
78
-
79
- Type: `object`
80
-
81
- Hash of options. Can also be set using the `marked.setOptions` method as seen
82
- above.
83
-
84
- ### callback
85
-
86
- Type: `function`
87
-
88
- Function called when the `markdownString` has been fully parsed when using
89
- async highlighting. If the `options` argument is omitted, this can be used as
90
- the second argument.
91
-
92
- ## Options
93
-
94
- ### highlight
95
-
96
- Type: `function`
97
-
98
- A function to highlight code blocks. The first example below uses async highlighting with
99
- [node-pygmentize-bundled][pygmentize], and the second is a synchronous example using
100
- [highlight.js][highlight]:
101
-
102
- ```js
103
- var marked = require('marked');
104
-
105
- var markdownString = '```js\n console.log("hello"); \n```';
106
-
107
- // Async highlighting with pygmentize-bundled
108
- marked.setOptions({
109
- highlight: function (code, lang, callback) {
110
- require('pygmentize-bundled')({ lang: lang, format: 'html' }, code, function (err, result) {
111
- callback(err, result.toString());
112
- });
113
- }
114
- });
115
-
116
- // Using async version of marked
117
- marked(markdownString, function (err, content) {
118
- if (err) throw err;
119
- console.log(content);
120
- });
121
-
122
- // Synchronous highlighting with highlight.js
123
- marked.setOptions({
124
- highlight: function (code) {
125
- return require('highlight.js').highlightAuto(code).value;
126
- }
127
- });
128
-
129
- console.log(marked(markdownString));
130
- ```
131
-
132
- #### highlight arguments
133
-
134
- `code`
135
-
136
- Type: `string`
137
-
138
- The section of code to pass to the highlighter.
139
-
140
- `lang`
141
-
142
- Type: `string`
143
-
144
- The programming language specified in the code block.
145
-
146
- `callback`
147
-
148
- Type: `function`
149
-
150
- The callback function to call when using an async highlighter.
151
-
152
- ### renderer
153
-
154
- Type: `object`
155
- Default: `new Renderer()`
156
-
157
- An object containing functions to render tokens to HTML.
158
-
159
- #### Overriding renderer methods
160
-
161
- The renderer option allows you to render tokens in a custom manner. Here is an
162
- example of overriding the default heading token rendering by adding an embedded anchor tag like on GitHub:
163
-
164
- ```javascript
165
- var marked = require('marked');
166
- var renderer = new marked.Renderer();
167
-
168
- renderer.heading = function (text, level) {
169
- var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
170
-
171
- return '<h' + level + '><a name="' +
172
- escapedText +
173
- '" class="anchor" href="#' +
174
- escapedText +
175
- '"><span class="header-link"></span></a>' +
176
- text + '</h' + level + '>';
177
- };
178
-
179
- console.log(marked('# heading+', { renderer: renderer }));
180
- ```
181
- This code will output the following HTML:
182
- ```html
183
- <h1>
184
- <a name="heading-" class="anchor" href="#heading-">
185
- <span class="header-link"></span>
186
- </a>
187
- heading+
188
- </h1>
189
- ```
190
-
191
- #### Block level renderer methods
192
-
193
- - code(*string* code, *string* language)
194
- - blockquote(*string* quote)
195
- - html(*string* html)
196
- - heading(*string* text, *number* level)
197
- - hr()
198
- - list(*string* body, *boolean* ordered)
199
- - listitem(*string* text)
200
- - paragraph(*string* text)
201
- - table(*string* header, *string* body)
202
- - tablerow(*string* content)
203
- - tablecell(*string* content, *object* flags)
204
-
205
- `flags` has the following properties:
206
-
207
- ```js
208
- {
209
- header: true || false,
210
- align: 'center' || 'left' || 'right'
211
- }
212
- ```
213
-
214
- #### Inline level renderer methods
215
-
216
- - strong(*string* text)
217
- - em(*string* text)
218
- - codespan(*string* code)
219
- - br()
220
- - del(*string* text)
221
- - link(*string* href, *string* title, *string* text)
222
- - image(*string* href, *string* title, *string* text)
223
- - text(*string* text)
224
-
225
- ### gfm
226
-
227
- Type: `boolean`
228
- Default: `true`
229
-
230
- Enable [GitHub flavored markdown][gfm].
231
-
232
- ### tables
233
-
234
- Type: `boolean`
235
- Default: `true`
236
-
237
- Enable GFM [tables][tables].
238
- This option requires the `gfm` option to be true.
239
-
240
- ### breaks
241
-
242
- Type: `boolean`
243
- Default: `false`
244
-
245
- Enable GFM [line breaks][breaks].
246
- This option requires the `gfm` option to be true.
247
-
248
- ### pedantic
249
-
250
- Type: `boolean`
251
- Default: `false`
252
-
253
- Conform to obscure parts of `markdown.pl` as much as possible. Don't fix any of
254
- the original markdown bugs or poor behavior.
255
-
256
- ### sanitize
257
-
258
- Type: `boolean`
259
- Default: `false`
260
-
261
- Sanitize the output. Ignore any HTML that has been input.
262
-
263
- ### smartLists
264
-
265
- Type: `boolean`
266
- Default: `true`
267
-
268
- Use smarter list behavior than the original markdown. May eventually be
269
- default with the old behavior moved into `pedantic`.
270
-
271
- ### smartypants
272
-
273
- Type: `boolean`
274
- Default: `false`
275
-
276
- Use "smart" typographic punctuation for things like quotes and dashes.
277
-
278
- ### xhtml
279
-
280
- Type: `boolean`
281
- Default: `false`
282
-
283
- Self-close the tags for void elements (&lt;br/&gt;, &lt;img/&gt;, etc.) with a "/" as required by XHTML.
284
-
285
- ## Access to lexer and parser
286
-
287
- You also have direct access to the lexer and parser if you so desire.
288
-
289
- ``` js
290
- var tokens = marked.lexer(text, options);
291
- console.log(marked.parser(tokens));
292
- ```
293
-
294
- ``` js
295
- var lexer = new marked.Lexer(options);
296
- var tokens = lexer.lex(text);
297
- console.log(tokens);
298
- console.log(lexer.rules);
299
- ```
300
-
301
- ## CLI
302
-
303
- ``` bash
304
- $ marked -o hello.html
305
- hello world
306
- ^D
307
- $ cat hello.html
308
- <p>hello world</p>
309
- ```
310
-
311
- ## Philosophy behind marked
312
-
313
- The point of marked was to create a markdown compiler where it was possible to
314
- frequently parse huge chunks of markdown without having to worry about
315
- caching the compiled output somehow...or blocking for an unnecessarily long time.
316
-
317
- marked is very concise and still implements all markdown features. It is also
318
- now fully compatible with the client-side.
319
-
320
- marked more or less passes the official markdown test suite in its
321
- entirety. This is important because a surprising number of markdown compilers
322
- cannot pass more than a few tests. It was very difficult to get marked as
323
- compliant as it is. It could have cut corners in several areas for the sake
324
- of performance, but did not in order to be exactly what you expect in terms
325
- of a markdown rendering. In fact, this is why marked could be considered at a
326
- disadvantage in the benchmarks.
327
-
328
- Along with implementing every markdown feature, marked also implements [GFM
329
- features][gfmf].
330
-
331
- ## Benchmarks
332
-
333
- node v8.9.4
334
-
335
- ``` bash
336
- $ npm run bench
337
- marked completed in 3408ms.
338
- marked (gfm) completed in 3465ms.
339
- marked (pedantic) completed in 3032ms.
340
- showdown (reuse converter) completed in 21444ms.
341
- showdown (new converter) completed in 23058ms.
342
- markdown-it completed in 3364ms.
343
- markdown.js completed in 12090ms.
344
- ```
345
-
346
- ### Pro level
347
-
348
- You also have direct access to the lexer and parser if you so desire.
349
-
350
- ``` js
351
- var tokens = marked.lexer(text, options);
352
- console.log(marked.parser(tokens));
353
- ```
354
-
355
- ``` js
356
- var lexer = new marked.Lexer(options);
357
- var tokens = lexer.lex(text);
358
- console.log(tokens);
359
- console.log(lexer.rules);
360
- ```
361
-
362
- ``` bash
363
- $ node
364
- > require('marked').lexer('> i am using marked.')
365
- [ { type: 'blockquote_start' },
366
- { type: 'paragraph',
367
- text: 'i am using marked.' },
368
- { type: 'blockquote_end' },
369
- links: {} ]
370
- ```
371
-
372
- ## Running Tests & Contributing
373
-
374
- If you want to submit a pull request, make sure your changes pass the test
375
- suite. If you're adding a new feature, be sure to add your own test.
376
-
377
- The marked test suite is set up slightly strangely: `test/new` is for all tests
378
- that are not part of the original markdown.pl test suite (this is where your
379
- test should go if you make one). `test/original` is only for the original
380
- markdown.pl tests.
381
-
382
- In other words, if you have a test to add, add it to `test/new/`. If your test
383
- uses a certain feature, for example, maybe it assumes GFM is *not* enabled, you
384
- can add [front-matter](https://www.npmjs.com/package/front-matter) to the top of
385
- your `.md` file
386
-
387
- ``` yml
388
- ---
389
- gfm: false
390
- ---
391
- ```
392
-
393
- To run the tests:
394
-
395
- ``` bash
396
- npm run test
397
- ```
398
-
399
- ### Contribution and License Agreement
400
-
401
- If you contribute code to this project, you are implicitly allowing your code
402
- to be distributed under the MIT license. You are also implicitly verifying that
403
- all code is your original work. `</legalese>`
404
-
405
64
  ## License
406
65
 
407
66
  Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
408
67
 
409
- See LICENSE for more info.
410
-
411
- [gfm]: https://help.github.com/articles/github-flavored-markdown
412
- [gfmf]: http://github.github.com/github-flavored-markdown/
413
- [pygmentize]: https://github.com/rvagg/node-pygmentize-bundled
414
- [highlight]: https://github.com/isagalaev/highlight.js
415
- [badge]: http://badge.fury.io/js/marked
416
- [tables]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#wiki-tables
417
- [breaks]: https://help.github.com/articles/github-flavored-markdown#newlines
package/bin/marked CHANGED
@@ -5,9 +5,9 @@
5
5
  * Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
6
6
  */
7
7
 
8
- var fs = require('fs')
9
- , util = require('util')
10
- , marked = require('../');
8
+ var fs = require('fs'),
9
+ path = require('path'),
10
+ marked = require('../');
11
11
 
12
12
  /**
13
13
  * Man Page
@@ -20,12 +20,12 @@ function help() {
20
20
  cwd: process.cwd(),
21
21
  env: process.env,
22
22
  setsid: false,
23
- customFds: [0, 1, 2]
23
+ stdio: 'inherit'
24
24
  };
25
25
 
26
- spawn('man', [__dirname + '/../man/marked.1'], options)
27
- .on('error', function(err) {
28
- fs.readFile(__dirname + '/../man/marked.1.txt', 'utf8', function(err, data) {
26
+ spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
27
+ .on('error', function() {
28
+ fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
29
29
  if (err) throw err;
30
30
  console.log(data);
31
31
  });
@@ -37,13 +37,14 @@ function help() {
37
37
  */
38
38
 
39
39
  function main(argv, callback) {
40
- var files = []
41
- , options = {}
42
- , input
43
- , output
44
- , arg
45
- , tokens
46
- , opt;
40
+ var files = [],
41
+ options = {},
42
+ input,
43
+ output,
44
+ string,
45
+ arg,
46
+ tokens,
47
+ opt;
47
48
 
48
49
  function getarg() {
49
50
  var arg = argv.shift();
@@ -86,6 +87,10 @@ function main(argv, callback) {
86
87
  case '--input':
87
88
  input = argv.shift();
88
89
  break;
90
+ case '-s':
91
+ case '--string':
92
+ string = argv.shift();
93
+ break;
89
94
  case '-t':
90
95
  case '--tokens':
91
96
  tokens = true;
@@ -118,6 +123,9 @@ function main(argv, callback) {
118
123
  function getData(callback) {
119
124
  if (!input) {
120
125
  if (files.length <= 2) {
126
+ if (string) {
127
+ return callback(null, string);
128
+ }
121
129
  return getStdin(callback);
122
130
  }
123
131
  input = files.pop();
@@ -146,8 +154,8 @@ function main(argv, callback) {
146
154
  */
147
155
 
148
156
  function getStdin(callback) {
149
- var stdin = process.stdin
150
- , buff = '';
157
+ var stdin = process.stdin,
158
+ buff = '';
151
159
 
152
160
  stdin.setEncoding('utf8');
153
161
 
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marked",
3
- "homepage": "https://github.com/chjj/marked",
3
+ "homepage": "https://github.com/markedjs/marked",
4
4
  "authors": [
5
5
  "Christopher Jeffrey <chjjeffrey@gmail.com>"
6
6
  ],
package/component.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "marked",
3
3
  "version": "0.3.4",
4
- "repo": "chjj/marked",
4
+ "repo": "markedjs/marked",
5
5
  "description": "A markdown parser built for speed",
6
6
  "keywords": ["markdown", "markup", "html"],
7
7
  "scripts": ["lib/marked.js"],