-
-
Save selsta/1082f90ae3fc7ce3af414e93ba37287a to your computer and use it in GitHub Desktop.
Transform IRC logs into Markdown (for Monero)
This file contains hidden or 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
#!/usr/bin/env node | |
// Usage: ./irc_to_markdown.js log.txt > log.md | |
// Still needs manuell edits afterwards. | |
require('fs').readFile(process.argv[2], (err, data) => { | |
if (err) return; | |
const content = data.toString().trim(); | |
const re = /^\[(.+?)\]\s+<(.+?)>\s(.*)$/gm; | |
const chat = []; | |
let current = {}; | |
while (match = re.exec(content)) { | |
chat.push(current = { | |
time: match[1], | |
name: match[2], | |
content: match[3] | |
}); | |
} | |
console.log(chat.map(user => | |
`**\\<${user.name}>** ${user.content.replace(/```[\S\s]+?```/g, $0 => $0.replace(/\n\n/g, '\n'))} ` | |
).join('\n')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment