Socket
Socket
Sign inDemoInstall

marked

Package Overview
Dependencies
Maintainers
1
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

24

lib/marked.js

@@ -534,5 +534,15 @@ /**

case 'code': {
if (options.highlight) {
token.code = options.highlight(token.text, token.lang);
if (token.code != null && token.code !== token.text) {
token.escaped = true;
token.text = token.code;
}
}
if (!token.escaped) {
token.text = escape(token.text, true);
}
return '<pre><code'
+ (token.lang
? ' class="'
? ' class="lang-'
+ token.lang

@@ -542,5 +552,3 @@ + '"'

+ '>'
+ (token.escaped
? token.text
: escape(token.text, true))
+ token.text
+ '</code></pre>\n';

@@ -743,2 +751,3 @@ }

setOptions(opt);
return marked;
};

@@ -749,3 +758,4 @@

pedantic: false,
sanitize: false
sanitize: false,
highlight: null
});

@@ -775,2 +785,4 @@

}).call(this);
}).call(function() {
return this || (typeof window !== 'undefined' ? window : global);
}());

@@ -5,3 +5,3 @@ {

"author": "Christopher Jeffrey",
"version": "0.2.3",
"version": "0.2.4",
"main": "./lib/marked.js",

@@ -8,0 +8,0 @@ "bin": "./bin/marked",

# marked
A full-featured markdown parser and compiler.
A full-featured markdown parser and compiler, written in javascript.
Built for speed.

@@ -37,4 +37,2 @@

Benchmarks for other engines to come (?).
## Install

@@ -46,3 +44,3 @@

## Another javascript markdown parser
## Another Javascript Markdown Parser

@@ -69,8 +67,9 @@ The point of marked was to create a markdown compiler where it was possible to

marked has 3 different switches which change behavior.
marked has 4 different switches which change behavior.
- __pedantic__: Conform to obscure parts of `markdown.pl` as much as possible.
Don't fix any of the original markdown bugs or poor behavior.
- __gfm__: Enabled github flavored markdown (default for backward compatibility).
- __gfm__: Enable github flavored markdown (enabled by default).
- __sanitize__: Sanitize the output. Ignore any HTML that has been input.
- __highlight__: A callback to highlight code blocks.

@@ -82,7 +81,14 @@ None of the above are mutually exclusive/inclusive.

``` js
// set default options
// Set default options
marked.setOptions({
gfm: true,
pedantic: false,
sanitize: true
sanitize: true,
// callback for code highlighter
highlight: function(code, lang) {
if (lang === 'js') {
return javascriptHighlighter(code);
}
return code;
}
});

@@ -95,3 +101,3 @@ console.log(marked('i am using __markdown__.'));

``` js
var tokens = marked.lexer(str);
var tokens = marked.lexer(text);
console.log(marked.parser(tokens));

@@ -104,3 +110,4 @@ ```

[ { type: 'blockquote_start' },
{ type: 'text', text: ' i am using marked.' },
{ type: 'paragraph',
text: 'i am using marked.' },
{ type: 'blockquote_end' },

@@ -120,36 +127,2 @@ links: {} ]

## Syntax Highlighting
Marked has an interface that allows for a syntax highlighter to highlight code
blocks before they're output.
Example implementation:
``` js
var highlight = require('my-syntax-highlighter')
, marked_ = require('marked');
var marked = function(text) {
var tokens = marked_.lexer(text)
, l = tokens.length
, i = 0
, token;
for (; i < l; i++) {
token = tokens[i];
if (token.type === 'code') {
token.text = highlight(token.text, token.lang);
// marked should not escape this
token.escaped = true;
}
}
text = marked_.parser(tokens);
return text;
};
module.exports = marked;
```
## License

@@ -156,0 +129,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc