markdown-pdf
Advanced tools
Comparing version 2.2.0 to 3.0.0
@@ -6,3 +6,3 @@ var system = require("system") | ||
// Read in arguments | ||
var args = ["in", "out", "runningsPath", "cssPath", "paperFormat", "paperOrientation", "paperBorder", "renderDelay", "jsonPath"].reduce(function (args, name, i) { | ||
var args = ["in", "out", "runningsPath", "cssPath", "highlightCssPath", "paperFormat", "paperOrientation", "paperBorder", "renderDelay", "jsonPath"].reduce(function (args, name, i) { | ||
args[name] = system.args[i + 1] | ||
@@ -21,13 +21,18 @@ return args | ||
// Add custom CSS to the page | ||
page.evaluate(function(cssPath) { | ||
page.evaluate(function(cssPaths) { | ||
var head = document.querySelector("head") | ||
var css = document.createElement("link") | ||
css.rel = "stylesheet" | ||
css.href = cssPath | ||
cssPaths.forEach(function(cssPath) { | ||
var css = document.createElement("link") | ||
css.rel = "stylesheet" | ||
css.href = cssPath | ||
head.appendChild(css) | ||
}); | ||
head.appendChild(css) | ||
}, args.cssPath) | ||
}, [args.cssPath, args.highlightCssPath]) | ||
@@ -34,0 +39,0 @@ // Add the HTML to the page |
@@ -6,2 +6,3 @@ var fs = require("fs") | ||
, marked = require("marked") | ||
, pygments = require('pygmentize-bundled') | ||
, tmp = require("tmp") | ||
@@ -18,3 +19,17 @@ , childProcess = require("child_process") | ||
opts.runningsPath = path.resolve(__dirname + "/..", opts.runningsPath || '') || __dirname + "/runnings.js" | ||
opts.cssPath = opts.cssPath || __dirname + "/../pdf.css" | ||
var relativeCssPath = path.resolve(process.cwd(), opts.cssPath) | ||
if (fs.existsSync(relativeCssPath)) { | ||
opts.cssPath = relativeCssPath | ||
} | ||
opts.highlightCssPath = opts.highlightCssPath || __dirname + "/../highlight.css" | ||
var relativeHighlightCssPath = path.resolve(process.cwd(), opts.highlightCssPath) | ||
if (fs.existsSync(relativeHighlightCssPath)) { | ||
opts.highlightCssPath = relativeHighlightCssPath | ||
} | ||
opts.paperFormat = opts.paperFormat || "A4" | ||
@@ -35,5 +50,17 @@ opts.paperOrientation = opts.paperOrientation || "portrait" | ||
function end () { | ||
var html = marked(md) | ||
this.queue(html) | ||
this.queue(null) | ||
var self = this | ||
// set options for marked | ||
var markedOptions = { | ||
highlight: function (code, lang, cb) { | ||
pygments({lang: lang, format: "html"}, code, function (er, result) { | ||
cb(null, result ? result.toString() : code) | ||
}) | ||
} | ||
} | ||
marked(md, markedOptions, function (er, html) { | ||
self.queue(html) | ||
self.queue(null) | ||
}) | ||
} | ||
@@ -68,2 +95,3 @@ ) | ||
, opts.cssPath | ||
, opts.highlightCssPath | ||
, opts.paperFormat | ||
@@ -70,0 +98,0 @@ , opts.paperOrientation |
{ | ||
"name": "markdown-pdf", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"description": "Markdown to PDF converter", | ||
@@ -33,14 +33,15 @@ "main": "index.js", | ||
"tmp": "~0.0.18", | ||
"commander": "~2.1.0", | ||
"commander": "^2.2.0", | ||
"through": "~2.3.4", | ||
"extend": "~1.2.1", | ||
"duplexer": "~0.1.1", | ||
"stream-from-to": "~1.4.0" | ||
"stream-from-to": "~1.4.0", | ||
"pygmentize-bundled": "~2.1.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.17.1", | ||
"mocha": "^1.20.1", | ||
"mocha-lcov-reporter": "0.0.1", | ||
"coveralls": "~2.7.0", | ||
"jscoverage": "~0.3.7", | ||
"pdf-text": "~0.3.0" | ||
"coveralls": "^2.10.0", | ||
"jscoverage": "^0.5.3", | ||
"pdf-text": "^0.4.0" | ||
}, | ||
@@ -47,0 +48,0 @@ "engines": { |
@@ -43,6 +43,12 @@ markdown-pdf [](https://travis-ci.org/alanshaw/markdown-pdf) [](https://david-dm.org/alanshaw/markdown-pdf) [](https://coveralls.io/r/alanshaw/markdown-pdf) | ||
Type: `String` | ||
Default value: `../pdf.css` | ||
Default value: `[module path]/markdown-pdf/pdf.css` | ||
Path to custom CSS file, relative to the html5bp directory | ||
Path to custom CSS file, relative to the current directory | ||
#### options.highlightCssPath | ||
Type: `String` | ||
Default value: `[module path]/markdown-pdf/highlight.css` | ||
Path to custom highlight CSS file (for code highlighting), relative to the current directory | ||
#### options.paperFormat | ||
@@ -213,2 +219,3 @@ Type: `String` | ||
-s, --css-path [path] Path to custom CSS file | ||
-z, --highlight-css-path [path] Path to custom highlight-CSS file | ||
-f, --paper-format [format] 'A3', 'A4', 'A5', 'Legal', 'Letter' or 'Tabloid' | ||
@@ -215,0 +222,0 @@ -r, --paper-orientation [orientation] 'portrait' or 'landscape' |
Sorry, the diff of this file is not supported yet
299795
52
1683
225
9
+ Addedpygmentize-bundled@~2.1.1
+ Addedbl@0.4.2(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedmkdirp@0.3.5(transitive)
+ Addedobject-keys@0.4.0(transitive)
+ Addedpygmentize-bundled@2.1.1(transitive)
+ Addedreadable-stream@1.0.341.1.14(transitive)
+ Addedthrough2@0.2.3(transitive)
+ Addedxtend@2.1.2(transitive)
- Removedcommander@2.1.0(transitive)
Updatedcommander@^2.2.0