1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Added support for SVG tiddlers

Which means adding a parser for SVG, even though it doesn't actually do
any parsing at the moment
This commit is contained in:
Jeremy Ruston 2012-01-12 19:17:32 +00:00
parent 6f247640c6
commit ecabcd676b
9 changed files with 52 additions and 2 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,3 @@
title: High Level Architecture.svg
modifier: JeremyRuston
type: image/svg+xml

View File

@ -15,6 +15,7 @@ var WikiStore = require("./WikiStore.js").WikiStore,
tiddlerOutput = require("./TiddlerOutput.js"),
WikiTextParser = require("./WikiTextParser.js").WikiTextParser,
JavaScriptParser = require("./JavaScriptParser.js").JavaScriptParser,
SVGParser = require("./SVGParser.js").SVGParser,
Navigators = require("./Navigators.js").Navigators,
StoryNavigator = require("./StoryNavigator.js").StoryNavigator;
@ -24,10 +25,11 @@ var App = function() {
this.isBrowser = typeof window !== "undefined";
// Create the main store
this.store = new WikiStore();
// Register the wikitext parser
// Register the wikitext parser and the SVG parser
this.store.registerParser("text/x-tiddlywiki",new WikiTextParser({
store: this.store
}));
this.store.registerParser("image/svg+xml",new SVGParser());
// Register the standard tiddler serializers and deserializers
tiddlerInput.register(this.store);
tiddlerOutput.register(this.store);

34
js/SVGParser.js Normal file
View File

@ -0,0 +1,34 @@
/*\
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 tiddler.fields.text;})";
} else {
return null;
}
};
var SVGParser = function() {
};
SVGParser.prototype.parse = function() {
return new SVGParseTree();
};
exports.SVGParser = SVGParser;
})();

View File

@ -30,7 +30,7 @@ exports.macro = {
return store.renderText(targetTiddler.fields.type,text,type,tiddler.fields.title);
} else {
// There's no parameterisation, so we can just render the target tiddler directly
return store.renderTiddler(type,params.target,tiddler.fields.title);
return store.renderTiddler(type,params.target);
}
}
};

View File

@ -94,3 +94,7 @@ a.linkInternalResolves {
a.linkInternalMissing {
font-style: italic;
}
svg {
width: 100%;
}

View File

@ -9,6 +9,8 @@ TiddlyWiki is based on the idea of making information more useful by modelling i
Tiddlers use a special wikitext notation that concisely represents text formatting and hypertext features. A cornerstone of wikitext is the ability to combine and embed tiddlers in various ways.
<<tiddler [[High Level Architecture.svg]]>>
!! Content Types
TiddlyWiki uses MIME types to indicate how the text of tiddlers should be interpreted. It uses standard MIME types such as {{{text/plain}}} and {{{text/html}}}, as well as these non-standard types for TiddlyWiki-specific formats:

View File

@ -4,6 +4,7 @@ style: styles.css
recipe: tiddlers/split.recipe
recipe: ../parsers/split.recipe
tiddler: ../docs/High Level Architecture.svg
jslib: ../test/tiddlywiki.2.6.5/source/tiddlywiki/jquery/jquery.js
@ -16,6 +17,7 @@ jsmodule: ../js/Tiddler.js
jsmodule: ../js/TiddlerInput.js
jsmodule: ../js/TiddlerOutput.js
jsmodule: ../js/WikiStore.js
jsmodule: ../js/SVGParser.js
jsmodule: ../js/WikiTextParser.js
jsmodule: ../js/WikiTextRules.js
jsmodule: ../js/WikiTextParseTree.js