Advertisement
MLSTRM

DL wiki colour replacement script

Jun 19th, 2021
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // To add colour formatting to Dustloop wiki combos for GG Strive.
  2. // Requires: NodeJS v10+
  3. // How to use: node this-files-name.js path-to-input path-to-output
  4.  
  5. function colourText(str){
  6. return moves.reduce((prev, curr, index) => {
  7. const patt = makePattern(curr, index+1);
  8. return prev.replace(patt.pattern, patt.replace);
  9. }, str);
  10. }
  11.  
  12. const moves = ['P','K','S','H(S?)','D']
  13.  
  14. function makePattern(move, num){
  15. return {
  16. pattern: new RegExp(`((([0-9\\[\\]]+)|((d)?j\\.[0-9\\[\\]]?)|(c\\.)|(f\\.))(\\[)?${move}(\\])?(\\s?\\([1-9]\\))?)`, 'ig'),
  17. replace: `{{clr|${num}|$1}}`
  18. };
  19. }
  20.  
  21. const [inputFile, outputFile] = process.argv.slice(2,4);
  22.  
  23. const fs = require('fs');
  24.  
  25. const input = fs.readFileSync(inputFile).toString();
  26.  
  27. fs.writeFileSync(outputFile, colourText(input));
  28. return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement