New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bisheng-plugin-local-img

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bisheng-plugin-local-img - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

56

lib/node.js

@@ -6,30 +6,44 @@ 'use strict';

function isLocalImg(src) {
return !/^https?:\/\/.*/i.test(src);
return !!src && !/^https?:\/\/.*/i.test(src);
}
function findImgElment(jml) {
if (JsonML.isElement(jml)) {
const children = JsonML.isElement(jml) ? JsonML.getChildren(jml) : [];
if (children.length < 2) {
jml = convert(jml);
} else {
children.forEach(child => {
findImgElment(child);
});
}
}
}
function convert(jml) {
if (JsonML.getTagName(jml) === 'img') {
console.log(jml);
const src = JsonML.getAttribute(jml, 'src');
if (isLocalImg(src)) {
return [
'pre',
{
lang: '__react',
},
['code', "ReactDOM.render(<img src={require('" + src + '\')} width="100px"/>, mountNode);'],
];
}
}
return jml;
}
module.exports = (markdownData, config) => {
const { content } = markdownData;
JsonML.getChildren(content);
// ignore customized content
if (Array.isArray(content)) {
markdownData.content = content.map(node => {
console.log(node);
const tagName = node[0];
const attr = node[1];
if (tagName === 'img' && attr && isLocalImg(attr.src)) {
const src = attr.src;
console.log(tagName, node);
/* const code = node[2][1];
const processedCode = transformer(code, babelConfig && JSON.parse(babelConfig), noreact);
return {
__BISHENG_EMBEDED_CODE: true,
code: processedCode,
}; */
}
return node;
});
if (markdownData.meta && markdownData.meta.title == '文档标题 也作为菜单名称') {
console.log('x');
if (Array.isArray(content)) {
markdownData.content = findImgElment(content);
}
}
return markdownData;
};
{
"name": "bisheng-plugin-local-img",
"version": "1.0.5",
"version": "1.0.6",
"description": "change <img> to React code block if src is local file path",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc