Created
February 13, 2023 11:02
-
-
Save farishan/cffb456e8b7365442ec0ab11f45e8bc7 to your computer and use it in GitHub Desktop.
Convert https://gist.github.com/farishan/4cdbc082ff19136522bdc5be1a28d754 to https://mermaid.live/ format
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
const fs = require('fs') | |
/* Configuration */ | |
const INPUT_PATH = './disciplines.txt' | |
const OUTPUT_PATH = './disciplines.mermaid.txt' | |
const ENCODING = 'utf-8' | |
const MINIFIED = false | |
const SPACE = 2 | |
const REPLACER = undefined | |
fs.readFile(INPUT_PATH, ENCODING, (err, data) => { | |
if (err) { | |
console.log(err) | |
console.log('error.') | |
} else { | |
const splitted = data.split(',') | |
let mermaidIds = [] | |
splitted.forEach(item => { | |
mermaidIds.push(`id_${item.toLowerCase().split(' ').join('_')}[${item}]`) | |
}); | |
const result = mermaidIds.join('\n') | |
fs.writeFile(OUTPUT_PATH, result, function (err) { | |
if (err) { | |
console.log(err) | |
console.log('error.') | |
} | |
}) | |
console.log('done.') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment