Skip to content

Commit

Permalink
beginning to convert markdown to amp-html #24
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcarlisle committed Dec 1, 2015
1 parent 5df3f5b commit ffa7b62
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/markdown-amp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var Remarkable = require('remarkable');
// var fs = require('fs');
// var post1 = fs.readFileSync(__dirname + '/../posts/post1.md');


// console.log(md.render(post1.toString()));

var md = new Remarkable('full');
module.exports = function parse(mdString) {
return md.render(mdString);
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "adoro is a simple writing/publishing tool",
"main": "lib/helpers.js",
"scripts": {
"test": "lab"
"test": "lab",
"tapetest": "tape tests/*.js"
},
"repository": {
"type": "git",
Expand All @@ -20,6 +21,11 @@
},
"homepage": "https:/nelsonic/adoro",
"dependencies": {
"marked": "^0.3.2"
"marked": "^0.3.2",
"remarkable": "^1.6.1"
},
"devDependencies": {
"amp-validator": "^0.1.3",
"tape": "^4.2.2"
}
}
1 change: 1 addition & 0 deletions posts/postlink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Click me](http://www.bbc.co.uk)
17 changes: 17 additions & 0 deletions tests/markdown-amp.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var test = require('tape');
var mdAmp = require('../lib/markdown-amp.js');
var fs = require('fs');
var mdFileString = fs.readFileSync(__dirname + '/../posts/postlink.md').toString();

test("testing heading parsed properly", function(t) {
var expected = '<h1>hello world</h1>\n';
t.equal(mdAmp('# hello world'), expected, 'WOOOOO!');
console.log(mdAmp(mdFileString));
t.end();
});

test("testing link parsed properly", function(t) {
var expected = '<p><a href="http://www.bbc.co.uk">Click me</a></p>\n';
t.equal(mdAmp(mdFileString), expected, 'SUCCESS!');
t.end();
});

0 comments on commit ffa7b62

Please sign in to comment.