Created
March 6, 2013 19:37
-
-
Save shobhitsharma/5102346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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