hexo-renderer-markdown-it
Advanced tools
Comparing version
'use strict'; | ||
const MarkdownIt = require('markdown-it'); | ||
const path = require('path'); | ||
class Renderer { | ||
/** | ||
@@ -20,5 +20,7 @@ * constructor | ||
markdown = { | ||
preset: markdown | ||
preset: markdown, | ||
}; | ||
hexo.log.warn(`Deprecated config detected. Please use\n\nmarkdown:\n preset: ${markdown.preset}\n\nSee https://github.com/hexojs/hexo-renderer-markdown-it#options`); | ||
hexo.log.warn( | ||
`Deprecated config detected. Please use\n\nmarkdown:\n preset: ${markdown.preset}\n\nSee https://github.com/hexojs/hexo-renderer-markdown-it#options` | ||
); | ||
} | ||
@@ -40,3 +42,15 @@ | ||
if (pugs instanceof Object && pugs.name) { | ||
return parser.use(require(pugs.name), pugs.options); | ||
const resolved = require.resolve(pugs.name, { | ||
paths: [ | ||
// find from root hexo base directory node_modules | ||
path.join(hexo.base_dir, 'node_modules'), | ||
// find from current installed library node_modules | ||
path.join(__dirname, '../node_modules'), | ||
// find from root hexo base directory | ||
hexo.base_dir, | ||
// find from current library directory | ||
path.join(__dirname, '../'), | ||
], | ||
}); | ||
return parser.use(require(resolved), pugs.options); | ||
} | ||
@@ -54,3 +68,3 @@ return parser.use(require(pugs)); | ||
images, | ||
hexo: this.hexo | ||
hexo: this.hexo, | ||
}); | ||
@@ -62,4 +76,10 @@ } | ||
this.hexo.execFilterSync('markdown-it:renderer', this.parser, { context: this }); | ||
if (options != null && options.inline === true) { | ||
return this.parser.renderInline(data.text, { | ||
postPath: data.path | ||
}); | ||
} | ||
return this.parser.render(data.text, { | ||
postPath: data.path | ||
postPath: data.path, | ||
}); | ||
@@ -66,0 +86,0 @@ } |
{ | ||
"name": "hexo-renderer-markdown-it", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "Markdown-it is a Markdown parser, done right. A faster and CommonMark compliant alternative for Hexo.", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"test": "mocha test/index.js", | ||
"test-cov": "nyc --reporter=lcovonly npm run test" | ||
"test-cov": "c8 --reporter=lcovonly npm run test" | ||
}, | ||
@@ -50,8 +50,8 @@ "repository": "hexojs/hexo-renderer-markdown-it", | ||
"devDependencies": { | ||
"chai": "^4.0.0", | ||
"eslint": "^8.6.0", | ||
"chai": "^4.3.7", | ||
"eslint": "^8.41.0", | ||
"eslint-config-hexo": "^5.0.0", | ||
"hexo": "^6.0.0", | ||
"mocha": "^10.0.0", | ||
"nyc": "^15.0.0" | ||
"hexo": "^6.3.0", | ||
"mocha": "^10.2.0", | ||
"c8": "^7.13.0" | ||
}, | ||
@@ -58,0 +58,0 @@ "engines": { |
@@ -66,2 +66,3 @@ # hexo-renderer-markdown-it | ||
post_asset: false | ||
inline: false # https://markdown-it.github.io/markdown-it/#MarkdownIt.renderInline | ||
``` | ||
@@ -68,0 +69,0 @@ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
21355
3.93%201
11.05%415
0.24%4
33.33%