Permalink
Browse files

add genOutput method

  • Loading branch information...
1 parent 023c49a commit 6019032baeec4d54c008cbc35f2354b8947269fd @jprichardson committed Jan 31, 2013
Showing with 27 additions and 19 deletions.
  1. +4 −0 CHANGELOG.md
  2. +1 −1 README.md
  3. +21 −17 lib/markdown-page.js
  4. +1 −1 package.json
View
4 CHANGELOG.md
@@ -1,3 +1,7 @@
+0.1.1 / 2013-01-31
+------------------
+* add `genOutput()` method
+
0.1.0 / 2013-01-23
------------------
* Fixed null body bug.
View
2 README.md
@@ -22,7 +22,7 @@ Installation
Example
------
-A bit unstable. See tests.
+Very unstable API. See tests.
View
38 lib/markdown-page.js
@@ -21,6 +21,26 @@
}});
}
+ MarkdownPage.prototype.genOutput = function() {
+ var data = '<!--\n'
+ , _this = this
+
+ Object.keys(this.metadata).forEach(function(key) {
+ if (_this.metadataConversions[key])
+ data += key + ': ' + _this.metadataConversions[key].serialize(_this.metadata[key]) + '\n';
+ else
+ data += key + ': ' + _this.metadata[key] + '\n'
+ })
+
+ data += '-->\n\n\n'
+
+ data += this.title + '\n'
+ data += S('=').repeat(this.title.length) + '\n\n'
+
+ data += this.markdown + '\n'
+ return data;
+ }
+
//this is actually just a sync method, but in the future, may call out to other executables or services
MarkdownPage.prototype.parse = function(callback) {
this.metadata = mde.metadata(this.text, parseMetadata);
@@ -40,23 +60,7 @@
}
MarkdownPage.prototype.writeFile = function(file, callback) {
- var data = '<!--\n'
- , _this = this
-
- Object.keys(this.metadata).forEach(function(key) {
- if (_this.metadataConversions[key])
- data += key + ': ' + _this.metadataConversions[key].serialize(_this.metadata[key]) + '\n';
- else
- data += key + ': ' + _this.metadata[key] + '\n'
- })
-
- data += '-->\n\n\n'
-
- data += this.title + '\n'
- data += S('=').repeat(this.title.length) + '\n\n'
-
- data += this.markdown + '\n'
-
+ var data = this.genOutput()
fs.writeFile(file, data, callback)
}
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "markdown-page",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "Parse a markdown article or page.",
"homepage": [
""

0 comments on commit 6019032

Please sign in to comment.