Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-plugin-plantuml-renderer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-plugin-plantuml-renderer - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

44

index.js

@@ -1,6 +0,4 @@

const plantumlEncoder = require('plantuml-encoder');
const http = require('http')
const plantuml = require('node-plantuml');
const crypto = require('crypto');
const contentTypes = ['image/png', 'image/svg+xml']
module.exports = {

@@ -13,30 +11,24 @@ blocks: {

const encoded = plantumlEncoder.encode(
block.body
.replace(/\\\//g, `/`)
.replace(/\\\[/g, `[`)
.replace(/\\\]/g, `]`)
.replace(/\\\(/g, `(`)
.replace(/\\\)/g, `)`)
.replace(/>/g, `>`)
.replace(/&lt;/g, `<`)
);
const hash = encoded.slice(0, 16);
const input = block.body
.replace(/\\\//g, `/`)
.replace(/\\\[/g, `[`)
.replace(/\\\]/g, `]`)
.replace(/\\\(/g, `(`)
.replace(/\\\)/g, `)`)
.replace(/&gt;/g, `>`)
.replace(/&lt;/g, `<`);
const hash = crypto.createHash('md5').update(input).digest('hex');
const name = block.kwargs.name || hash;
const path = `/plantuml/${hash}.${format}`;
const href = `http://www.plantuml.com/plantuml/${format}/${encoded}`;
return new Promise((resolve, reject) => {
const request = http.get(href, (response) => {
const body = [];
response.on('data', (chunk) => body.push(chunk));
response.on('end', () => {
if (!contentTypes.includes(response.headers['content-type'])) {
reject(new Error(`Failed to load picture "${href}", response code: ${response.statusCode}`));
}
plantuml.generate(input, {format: format}, (error, result) => {
if (error) {
reject(error);
return
}
resolve(body.join(''))
});
resolve(result);
});
request.on('error', (err) => reject(err));
}).then(body => {

@@ -43,0 +35,0 @@ return this.output.writeFile(path, body);

@@ -8,5 +8,5 @@ {

"dependencies": {
"plantuml-encoder": "^1.2.5"
"node-plantuml": "^0.7.0"
},
"description": "UML Diagrams rendering using PlantUML.com",
"description": "UML Diagrams rendering using PlantUML",
"engines": {

@@ -18,3 +18,3 @@ "gitbook": ">=2.0.0"

"name": "gitbook-plugin-plantuml-renderer",
"version": "1.2.0"
"version": "2.0.0"
}

Sorry, the diff of this file is not supported yet

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