Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Tweak the readme and package.json

  • Loading branch information...
commit 50390787162b7470df2663eb2cf082c2a5f65537 1 parent 6163dad
@joehewitt authored
Showing with 3 additions and 71 deletions.
  1. +1 −1  README.md
  2. +2 −2 package.json
  3. +0 −68 test/markdom-test.js
View
2  README.md
@@ -8,7 +8,7 @@ Markdom uses the Upskirt library to parse Markdom and transform it to HTML. Opti
Installation
------------
- $ npm install markdom (not yet, it's not published)
+ $ npm install markdom
License
-------
View
4 package.json
@@ -1,10 +1,10 @@
{
"name": "markdom",
"description": "Markdown parser based on upskirt",
- "url": "http://github.com/joehewitt/markdom",
+ "homepage": "http://github.com/joehewitt/markdom",
"repository": {
"type": "git",
- "url" : "http://github.com/joehewitt/markdom"
+ "url" : "http://github.com/joehewitt/markdom.git"
},
"author": "Joe Hewitt <joe@joehewitt.com>",
"keywords": ["markdown", "upskirt"],
View
68 test/markdom-test.js
@@ -5,16 +5,9 @@ var path = require('path'),
require.paths.unshift(path.join(__dirname, '..', 'lib'));
var markdom = require('markdom');
-var flickr = require('flickr-reflection');
var fs = require('fs');
var _ = require('underscore');
-var flickrOptions = {
- key: '379e503c91f1a375a1e8d1cc4b319caf',
- secret: '6f933c11df597e28',
- apis: ['photos']
-};
-
// *************************************************************************************************
vows.describe('markdom basics').addBatch({
@@ -22,67 +15,6 @@ vows.describe('markdom basics').addBatch({
topic: 'blah',
testNothing: function() {
- fs.readFile('/Users/joehewitt/Code/tests/markdom.md', 'utf8', function(err, body) {
- var transformer = new FlickrTransformer();
- var html = markdom.toDOM(body, {}, transformer);
- transformer.loadImages(function() {
- console.log(html.toHTML());
- });
- // console.log(markdom.toHTML(body));
- });
}
},
}).export(module);
-
-// *************************************************************************************************
-
-function FlickrTransformer() {
- this.flickrImages = [];
-}
-
-FlickrTransformer.prototype = _.extend(new markdom.NodeTransformer(), {
- rePhotoURL: /http:\/\/(.*?)\.flickr\.com\/photos\/(.*?)\/(.*?)\//,
-
- header: function(node) {
- if (node.level == 1) {
- return new markdom.nodeTypes.Text('');
- } else {
- return node;
- }
- },
-
- image: function(node) {
- var flickrURL = node.url;
- var m = this.rePhotoURL.exec(flickrURL);
- if (m) {
- var photoId = m[3];
-
- var newImage = new markdom.nodeTypes.Image('');
- this.flickrImages[photoId] = newImage;
- var link = new markdom.nodeTypes.Link(flickrURL, null, newImage);
- return link;
- }
- },
-
- loadImages: function(cb) {
- flickr.connect(flickrOptions, _.bind(function(err, api) {
- if (err) throw err;
-
- for (var photoId in this.flickrImages) {
- api.photos.getSizes({photo_id: photoId}, _.bind(function(err, data) {
- if (err) throw err;
-
- for (var i = 0; i < data.sizes.size.length; ++i) {
- var sizeInfo = data.sizes.size[i];
- if (sizeInfo.width > 600) {
- this.flickrImages[photoId].url = sizeInfo.source;
- cb();
- break;
- }
- }
- }, this));
- }
- }, this));
-
- }
-});
Please sign in to comment.
Something went wrong with that request. Please try again.