Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Create sub-modules for the text modification functions
- Loading branch information
1 parent
b1924a0
commit dde9b36
Showing
3 changed files
with
125 additions
and
66 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
var fs = require("fs"); | ||
var config = undefined; | ||
|
||
module.exports.init = function(c){ | ||
config = c; | ||
} | ||
|
||
|
||
module.exports.addTab = function(txt){ | ||
txt = txt.replace(/\n/g, "\n"+config.tab); | ||
return config.tab+txt; | ||
} | ||
|
||
module.exports.addBack = function(txt, add, remove){ | ||
remove = remove || ""; | ||
add = add.replace(remove, ""); | ||
return add+txt; | ||
} | ||
|
||
module.exports.getFirstLine = function(md){ | ||
var index = md.indexOf("\n"); | ||
var out = md.substring(0, index); | ||
return out.replace(/\n/gm, ""); | ||
} | ||
|
||
module.exports.loadFiles = function(files){ | ||
var result = {}; | ||
|
||
for(var i=0; i<files.length; i++){ | ||
var file = files[i]; | ||
var content = fs.readFileSync(file, 'ascii'); | ||
result[file] = content; | ||
} | ||
|
||
return result; | ||
} |