Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Campfire Transcript
#!/usr/bin/env coffee
fs = require 'fs'
log = fs.readFileSync('log.txt', 'utf8')
lines = log.split('\n')
lines = lines.filter (line) -> not /\thas entered the room$/.test(line)
lines = lines.filter (line) -> not /\thas left the room$/.test(line)
lines = lines.map (line, index) ->
if /\d?\d:\d\d [AP]M/.test(line)
"_#{line}_"
else
tab = line.indexOf '\t'
if tab > 0
author = line.substring(0, tab).trim()
message = line.substring(tab).trim()
"__#{author}__: #{message}"
else
line
fs.writeFileSync('log.md', lines.join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment