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

code2png

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code2png - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

package.json
{
"name": "code2png",
"version": "1.0.0",
"version": "1.1.0",
"description": "Generate PNGs of syntax-highlighted code",

@@ -5,0 +5,0 @@ "engines": {

@@ -20,2 +20,17 @@ code2png

Usage
-------------------------------------------------------------------------------
Pass a source file by name:
```sh
$ code2png foo.c -o foo.png
```
...or pipe it in:
```sh
$ cat foo.c | code2png -o foo.png
```
TODO

@@ -22,0 +37,0 @@ -------------------------------------------------------------------------------

@@ -7,13 +7,16 @@ const fs = require('fs');

const template = `<!DOCTYPE html>
<!-- Generated by code2png; do not edit directly.
- See: https://github.com/rjz/code2png
-->
<html>
<head>
<head>
<meta charset="utf-8" />
<title>Index</title>
<title>code2png</title>
{{#styles}}
<style type="text/css">{{{.}}}</style>
{{/styles}}
</head>
<body>
</head>
<body>
<pre>{{{code}}}</pre>
</body>
</body>
</html>`;

@@ -23,12 +26,19 @@

module.exports = ({ code }) => {
module.exports = ({
code,
language,
theme,
}) => {
const styles = loadFiles([
'css/default.css',
'node_modules/prismjs/themes/prism-okaidia.css',
`node_modules/prismjs/themes/prism-${theme}.css`,
].map(p => resolve(__dirname, `../${p}`)));
// Phantom truncates box-model whitespace; pad the EOL with cdata instead.
const paddedCode = code.split('\n').join(' \n');
return Mustache.render(template, {
code: Prism.highlight(code, Prism.languages.javascript),
code: Prism.highlight(paddedCode, Prism.languages[language]),
styles,
});
};

Sorry, the diff of this file is not supported yet

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