-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathafs2pan
executable file
·23 lines (19 loc) · 945 Bytes
/
afs2pan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env node
const fs = require('fs');
const process = require('process');
const c8b = require('./lib/conv8bitBuffer') // converts tm and (c) 8-bit chars
const cvs = require('./lib/convSymbols') // converts ~~ and other inline markup
const cl = require('./lib/convLine') // converts whole line markup, CHAPTER, SECTION, PROGRAM
function procChapter( c ) { //console.log(`chapter ${c}`);
const data = fs.readFileSync(c); //console.log(`${c}: data ${data.length}`);
const lines = c8b.conv8bitBuffer(data).split('\n') // converts tm and (c)
let curState = 'normal';
lines.forEach( l => {
({ l:l, cs:curState } = cl.convLine(l, curState)) // tracks state and outputs markdown
console.log(l)
});
}
const D = "archive/";
let bookChaps = (process.argv.length == 2) ? [ 'CH00R.txt'] : process.argv.slice(2);
console.error(`doing: ${bookChaps}`);
bookChaps.map( c => D+c ).forEach( c => procChapter(c) );