mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
102724b3e8
Embed the SVG image in an IMG tag rather than directly, to ensure that it has it's own DOM state (otherwise things like IDs in SVG images are visible to the hosting page)
35 lines
641 B
JavaScript
35 lines
641 B
JavaScript
/*\
|
|
title: js/SVGParser.js
|
|
|
|
Compiles SVG images into JavaScript functions that render them in HTML
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true */
|
|
"use strict";
|
|
|
|
// The parse tree is degenerate
|
|
var SVGParseTree = function() {
|
|
this.dependencies = [];
|
|
};
|
|
|
|
SVGParseTree.prototype.compile = function(type) {
|
|
if(type === "text/html") {
|
|
return "(function (tiddler,store,utils) {return '<img src=\"data:' + tiddler.type + ',' + encodeURIComponent(tiddler.text) + '\">';})";
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
|
|
var SVGParser = function() {
|
|
};
|
|
|
|
SVGParser.prototype.parse = function() {
|
|
return new SVGParseTree();
|
|
};
|
|
|
|
exports.SVGParser = SVGParser;
|
|
|
|
})();
|