Skip to content

Instantly share code, notes, and snippets.

@wizardforcel
Last active July 5, 2017 13:41
Show Gist options
  • Save wizardforcel/9ec348fcafef21434bc271f6b5358b01 to your computer and use it in GitHub Desktop.
Save wizardforcel/9ec348fcafef21434bc271f6b5358b01 to your computer and use it in GitHub Desktop.
split a html file
var fs = require('fs');
try {fs.mkdirSync('out');}
catch(ex){}
var co = fs.readFileSync('out.html', 'utf-8');
var files = co.split(/<!\-\-split\-\->/g);
//var summary = '';
//var pre = "{% raw %}\n",
// sub = "\n{% endraw %}";
for(var i = 0; i < files.length; i++)
{
fs.writeFileSync('out/' + i + '.html', files[i], {encoding: 'utf-8'});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment