Comparing version 1.0.0 to 1.1.0
{ | ||
"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
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
78
44
15815