diff --git a/.gitignore b/.gitignore index 13fbd72..b32672d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ results node_modules npm-debug.log samples +tmp_samples diff --git a/main.js b/main.js index 346a159..7ca0beb 100644 --- a/main.js +++ b/main.js @@ -5,7 +5,7 @@ var path = require('path'), file = require('./lib/file'); // TODO: from commandline -var dir = 'samples'; +var dir = 'tmp_samples'; function isAbsolute(path) { if ('/' == path[0]) return true; @@ -30,13 +30,29 @@ function transformAndSave(files, fcb) { } function transform (f, content, cb) { - console.log('transforming', f); - console.log(content); + console.log('transforming', f.name); + var lines = content.split('\n'); + var hashedLines = _(lines) + .chain() + .map(function (x) { + var match = /^(\#{1,8}) *(.+)$/.exec(x); + if (match) { + return { + rank : match[1].length, + title : match[2] + }; + } else { + return null; + } + }) + .filter(function (x) { return x !== null; }) + .value(); + + console.log(hashedLines); + cb(); } - - file.findMarkdownFiles(target, function (files) { transformAndSave(files, function () { console.log('Everything is OK'); }); });