Skip to content

Instantly share code, notes, and snippets.

@shobhitsharma
Created March 6, 2013 19:37
Show Gist options
  • Save shobhitsharma/5102346 to your computer and use it in GitHub Desktop.
Save shobhitsharma/5102346 to your computer and use it in GitHub Desktop.
/**
* User: kobkrit
* Date: 5/18/12
* Time: 2:44 PM
*/
var data = "";
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
data += chunk;
});
process.stdin.on('end', function () {
//Delete attribute and value
data = data.replace(/\\(cite|label|begin|end|ref|footnote|keywords)\{[^\}]+\}/g, "");
//Delete attribute
data = data.replace(/\\(item)/g, "");
//Delete attribute but not value
//External_Bucket \textbf{aaaa} => aaaa
data = data.replace(/\\(textbf|superscript|subscript)\{([^\}]+)\}/g, "$2\n");
//Internal_Bucket {\bf aaaa} => aaaa
data = data.replace(/\{\\(bf|it|ul)\s+([^\}]+)\}/g, "$2\n");
//Line indentation
data = data.replace(/\n{2,}/gm,"~~~~~~~~~~");
data = data.replace(/\n/gm, " ");
data = data.replace(/~~~~~~~~~~/gm,"\n\n");
process.stdout.write(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment