markdown-pdf
Advanced tools
Comparing version 5.3.0 to 6.0.0
18
index.js
@@ -29,3 +29,5 @@ var fs = require("fs") | ||
opts.remarkable = opts.remarkable || {} | ||
opts.remarkable.preset = opts.remarkable.preset || 'default' | ||
opts.remarkable.plugins = opts.remarkable.plugins || [] | ||
opts.remarkable.syntax = opts.remarkable.syntax || [] | ||
@@ -42,3 +44,3 @@ var md = "" | ||
var mdParser = new Remarkable(extend({ | ||
var mdParser = new Remarkable(opts.remarkable.preset, extend({ | ||
highlight: function (str, lang) { | ||
@@ -65,2 +67,16 @@ if (lang && hljs.getLanguage(lang)) { | ||
}) | ||
opts.remarkable.syntax.forEach(function(rule) | ||
{ | ||
try { | ||
mdParser.core.ruler.enable([rule]) | ||
} catch (er) {} | ||
try { | ||
mdParser.block.ruler.enable([rule]) | ||
} catch (er) {} | ||
try { | ||
mdParser.inline.ruler.enable([rule]) | ||
} catch (er) {} | ||
}) | ||
@@ -67,0 +83,0 @@ self.push(mdParser.render(md)) |
{ | ||
"name": "markdown-pdf", | ||
"version": "5.3.0", | ||
"version": "6.0.0", | ||
"description": "Markdown to PDF converter", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"duplexer": "^0.1.1", | ||
"extend": "^2.0.0", | ||
"extend": "^3.0.0", | ||
"highlight.js": "^8.4.0", | ||
@@ -37,10 +37,10 @@ "phantomjs": "^1.9.13", | ||
"stream-from-to": "^1.4.2", | ||
"through2": "^0.6.3", | ||
"tmp": "0.0.24" | ||
"through2": "^2.0.0", | ||
"tmp": "0.0.28" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "^2.10.0", | ||
"istanbul": "^0.3.5", | ||
"istanbul": "^0.4.0", | ||
"pdf-text": "^0.4.0", | ||
"tape": "^3.0.3" | ||
"tape": "^4.2.2" | ||
}, | ||
@@ -47,0 +47,0 @@ "engines": { |
@@ -113,2 +113,10 @@ markdown-pdf [![Build Status](https://travis-ci.org/alanshaw/markdown-pdf.svg)](https://travis-ci.org/alanshaw/markdown-pdf) [![Dependency Status](https://david-dm.org/alanshaw/markdown-pdf.svg)](https://david-dm.org/alanshaw/markdown-pdf) [![Coverage Status](https://img.shields.io/coveralls/alanshaw/markdown-pdf.svg?style=flat)](https://coveralls.io/r/alanshaw/markdown-pdf?branch=master) | ||
##### options.remarkable.preset | ||
Type: `String` | ||
Default value: `default` | ||
Use remarkable [presets](https://www.npmjs.com/package/remarkable#presets) as a convenience to quickly enable/disable active syntax rules and options for common use cases. | ||
Supported values are `default`, `commonmark` and `full` | ||
##### options.remarkable.plugins | ||
@@ -120,2 +128,8 @@ Type: `Array` of remarkable-plugin `Function`s | ||
##### options.remarkable.syntax | ||
Type: `Array` of optional remarkable syntax `Strings`s | ||
Default value: `[]` | ||
An array of [optional Remarkable syntax extensions](https://github.com/jonschlinkert/remarkable#syntax-extensions), disabled by default, that extend the markdown parser functionality. | ||
API | ||
@@ -231,3 +245,4 @@ --- | ||
breaks: true, | ||
plugins: [ require('remarkable-classy') ] | ||
plugins: [ require('remarkable-classy') ], | ||
syntax: [ 'footnote', 'sup', 'sub' ] | ||
} | ||
@@ -234,0 +249,0 @@ } |
@@ -151,3 +151,27 @@ var fs = require("fs") | ||
test("should accept remarkable preset", function(t) { | ||
t.plan(2) | ||
var html = "" | ||
var opts = { | ||
remarkable: {preset: 'full'}, | ||
preProcessHtml: function () { | ||
return through( | ||
function transform (chunk, enc, cb) { html += chunk; cb(); }, | ||
function flush (cb) { | ||
htmlSupTagFound = (html.indexOf("<sup>st</sup>") > -1); | ||
t.ok(htmlSupTagFound, "html <sup> tag not found for preset 'full'") | ||
cb(); | ||
} | ||
) | ||
} | ||
} | ||
// Preset 'full' - expecting <sup>-tag in html | ||
markdownpdf(opts).from.string("1^st^ of January").to.string(function (er, pdfStr) { | ||
t.ifError(er) | ||
t.end() | ||
}) | ||
}) | ||
test("should initialize remarkable plugins", function(t) { | ||
@@ -154,0 +178,0 @@ t.plan(2) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
251599
1470
287
4
+ Addedos-tmpdir@1.0.2(transitive)
+ Addedtmp@0.0.28(transitive)
- Removedextend@2.0.2(transitive)
- Removedisarray@0.0.1(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedthrough2@0.6.5(transitive)
- Removedtmp@0.0.24(transitive)
Updatedextend@^3.0.0
Updatedthrough2@^2.0.0
Updatedtmp@0.0.28