1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 10:37:20 +00:00
TiddlyWiki5/js/ImageParser.js
Jeremy Ruston 103a9a4d7f Introduced new Dependency() class to encapsulate dependency handling logic
Note that the format is now slightly different; see js/Dependencies.js
for details
2012-02-17 14:11:25 +00:00

34 lines
828 B
JavaScript

/*\
title: js/ImageParser.js
Compiles images into JavaScript functions that render them in HTML
\*/
(function(){
/*jslint node: true */
"use strict";
var WikiTextParseTree = require("./WikiTextParseTree.js").WikiTextParseTree,
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") {
src = "data:" + type + "," + encodeURIComponent(text);
} else {
src = "data:" + type + ";base64," + text;
}
return new WikiTextParseTree([Renderer.ElementNode("img",{src: src})],new Dependencies(),this.store);
};
exports.ImageParser = ImageParser;
})();