Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
build() {
const files = fs.readdirSync(nomnomlSourceDir);
while (files.length > 0) {
const file = path.resolve(nomnomlSourceDir, files.shift());
const basename = path.basename(file, 'txt');
if (/.nomnoml/.test(basename)) {
const fileContents = fs.readFileSync(file, 'utf-8');
const generated = nomnoml.renderSvg(fileContents);
const newFilePath = path.join(docImageDir, basename) + 'svg';
const outFile = fs.createWriteStream(newFilePath);
console.log(`wrote file ${newFilePath}`);
outFile.write(generated);
}
}
}
};
function convert () {
const source = data.toString(encoding)
if (source === '') {
return
}
console.log(nomnoml.renderSvg(source))
}
private generateDiagram( text: string ): string {
let svg : string;
let backgroundColor : string = undefined;
try {
svg = nomnoml.renderSvg( text );
let result = /\#bgColor\:\s?(\S*)/.exec( text );
if( result && result[ 1 ] )
backgroundColor = result[ 1 ];
} catch( exception ){
return this.errorSnippet( exception );
}
return `
<div style="width: 100%; height: 100%; overflow: scroll;">
${ svg }
</div>
public doDownloadSvg(name): void {
const svg = nomnoml.renderSvg(this.source, this.canvas.nativeElement);
const blob = new Blob([svg], {type: 'image/svg+xml'});
const filename = name;
saveFile(blob, filename, 'image/svg+xml');
}