jstransformer-marked
Advanced tools
Comparing version 1.2.0 to 1.3.0
20
index.js
@@ -1,2 +0,2 @@ | ||
const marked = require('marked').marked | ||
const {marked} = require('marked') | ||
@@ -10,5 +10,19 @@ const transformer = { | ||
transformer.render = function (string, options) { | ||
return marked(string, options) | ||
return marked(string, { ...options, async: false }) | ||
} | ||
module.exports = transformer | ||
// Marked doesn't really support async rendering, but this enables async walkTokens extensions, | ||
// see https://marked.js.org/using_pro#async | ||
transformer.renderAsync = function (string, options) { | ||
const rendered = marked(string, { | ||
...options, | ||
async: true, | ||
}) | ||
if (rendered instanceof Promise) { | ||
return rendered | ||
} | ||
return Promise.resolve(rendered) | ||
} | ||
module.exports = transformer |
{ | ||
"name": "jstransformer-marked", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Marked support for JSTransformers.", | ||
@@ -10,3 +10,3 @@ "keywords": [ | ||
"dependencies": { | ||
"marked": "^4.0.17" | ||
"marked": "^4.2.12" | ||
}, | ||
@@ -13,0 +13,0 @@ "files": [ |
@@ -16,3 +16,3 @@ # jstransformer-marked | ||
```js | ||
let marked = require('jstransformer')(require('jstransformer-marked')); | ||
const marked = require('jstransformer')(require('jstransformer-marked')); | ||
@@ -24,4 +24,16 @@ marked.render('# Hello World!').body | ||
marked.render('# "Hello World"', markedOptions) | ||
// also supports async walkTokens | ||
marked.renderAsync('# Hello World', { | ||
walkTokens: async (token) => { | ||
const uriPrefix = await uriPrefixAsync() | ||
if (token.href) { | ||
token.href = uriPrefix + token.href | ||
} | ||
} | ||
}) | ||
``` | ||
For all supported options see https://marked.js.org/using_advanced#options | ||
## License | ||
@@ -32,2 +44,2 @@ | ||
[ci-badge]: https://github.com/jstransformers/jstransformer-marked/actions/workflows/test.yml/badge.svg | ||
[ci-url]: https://github.com/jstransformers/jstransformer-marked/actions/workflows/test.yml | ||
[ci-url]: https://github.com/jstransformers/jstransformer-marked/actions/workflows/test.yml |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3911
22
43
0
4
Updatedmarked@^4.2.12