Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: chjj/marked
...
head fork: chjj/marked
  • 4 commits
  • 3 files changed
  • 3 commit comments
  • 1 contributor
Showing with 16 additions and 9 deletions.
  1. +4 −4 README.md
  2. +11 −4 lib/marked.js
  3. +1 −1  package.json
View
8 README.md
@@ -62,7 +62,7 @@ Along with implementing every markdown feature, marked also implements
## Options
-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.
@@ -81,9 +81,9 @@ marked.setOptions({
pedantic: false,
sanitize: true,
// callback for code highlighter
- highlight: function(code, language) {
- if (language === 'js') {
- code = highlight(code);
+ highlight: function(code, lang) {
+ if (lang === 'js') {
+ return javascriptHighlighter(code);
}
return code;
}
View
15 lib/marked.js
@@ -531,10 +531,15 @@ var tok = function() {
+ '>\n';
}
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 = options.highlight
- ? options.highlight(token.text, token.lang)
- : escape(token.text, true);
+ token.text = escape(token.text, true);
}
return '<pre><code'
+ (token.lang
@@ -773,4 +778,6 @@ if (typeof module !== 'undefined') {
this.marked = marked;
}
-}).call(this);
+}).call(function() {
+ return this || (typeof window !== 'undefined' ? window : global);
+}());
View
2  package.json
@@ -2,7 +2,7 @@
"name": "marked",
"description": "A markdown parser built for speed",
"author": "Christopher Jeffrey",
- "version": "0.2.3",
+ "version": "0.2.4",
"main": "./lib/marked.js",
"bin": "./bin/marked",
"man": "./man/marked.1",

Showing you all comments on commits in this comparison.

@mainiak

Why 'return this || ...' when this should exists always, no?

@aplib

This code can be wrapped and the call can change this, possibly null and undefined. This is not quite correct the situation, but I is met.

@mainiak

Ok, thank you!

Something went wrong with that request. Please try again.