1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-06 01:56:20 +00:00
TiddlyWiki5/js/ImageParser.js
Jeremy Ruston 7f136dd898 Get rid of the old WikiTextParseTree class
And replace it with a new root Renderer() class
2012-03-03 18:33:16 +00:00

33 lines
762 B
JavaScript

/*\
title: js/ImageParser.js
Compiles images into JavaScript functions that render them in HTML
\*/
(function(){
/*jslint node: true */
"use strict";
var Renderer = require("./Renderer.js").Renderer,
Dependencies = require("./Dependencies.js").Dependencies,
utils = require("./Utils.js");
var ImageParser = function(options) {
this.store = options.store;
};
ImageParser.prototype.parse = function(type,text) {
var src;
if(type === "image/svg+xml" || type === ".svg") {
src = "data:image/svg+xml," + encodeURIComponent(text);
} else {
src = "data:" + type + ";base64," + text;
}
return new Renderer([Renderer.ElementNode("img",{src: src})],new Dependencies(),this.store);
};
exports.ImageParser = ImageParser;
})();