mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-27 14:48:19 +00:00
Add support for multi-tiddler files with a .tids extension
This commit is contained in:
parent
a2cbc2deb5
commit
1f41daf433
24
boot/boot.js
24
boot/boot.js
@ -992,6 +992,29 @@ $tw.modules.define("$:/boot/tiddlerdeserializer/tid","tiddlerdeserializer",{
|
|||||||
return [fields];
|
return [fields];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$tw.modules.define("$:/boot/tiddlerdeserializer/tids","tiddlerdeserializer",{
|
||||||
|
"application/x-tiddlers": function(text,fields) {
|
||||||
|
var tiddlers = [],
|
||||||
|
split = text.split(/\r?\n\r?\n/mg);
|
||||||
|
if(split.length >= 2) {
|
||||||
|
fields = $tw.utils.parseFields(split[0],fields);
|
||||||
|
var lines = split[1].split(/\r?\n/mg);
|
||||||
|
for(var t=0; t<lines.length; t++) {
|
||||||
|
var line = lines[t];
|
||||||
|
if(line.charAt(0) !== "#") {
|
||||||
|
var parts = line.split(/:\s+/);
|
||||||
|
if(parts.length >= 2) {
|
||||||
|
var tiddler = $tw.utils.extend({},fields);
|
||||||
|
tiddler.title = (tiddler.title || "") + parts[0];
|
||||||
|
tiddler.text = parts[1];
|
||||||
|
tiddlers.push(tiddler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tiddlers;
|
||||||
|
}
|
||||||
|
});
|
||||||
$tw.modules.define("$:/boot/tiddlerdeserializer/txt","tiddlerdeserializer",{
|
$tw.modules.define("$:/boot/tiddlerdeserializer/txt","tiddlerdeserializer",{
|
||||||
"text/plain": function(text,fields,type) {
|
"text/plain": function(text,fields,type) {
|
||||||
fields.text = text;
|
fields.text = text;
|
||||||
@ -1479,6 +1502,7 @@ $tw.boot.startup = function(options) {
|
|||||||
// Add file extension information
|
// Add file extension information
|
||||||
$tw.utils.registerFileType("text/vnd.tiddlywiki","utf8",".tid");
|
$tw.utils.registerFileType("text/vnd.tiddlywiki","utf8",".tid");
|
||||||
$tw.utils.registerFileType("application/x-tiddler","utf8",".tid");
|
$tw.utils.registerFileType("application/x-tiddler","utf8",".tid");
|
||||||
|
$tw.utils.registerFileType("application/x-tiddlers","utf8",".tids");
|
||||||
$tw.utils.registerFileType("application/x-tiddler-html-div","utf8",".tiddler");
|
$tw.utils.registerFileType("application/x-tiddler-html-div","utf8",".tiddler");
|
||||||
$tw.utils.registerFileType("text/vnd.tiddlywiki2-recipe","utf8",".recipe");
|
$tw.utils.registerFileType("text/vnd.tiddlywiki2-recipe","utf8",".recipe");
|
||||||
$tw.utils.registerFileType("text/plain","utf8",".txt");
|
$tw.utils.registerFileType("text/plain","utf8",".txt");
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
created: 20140209143652456
|
||||||
|
tags: deserializers dev
|
||||||
|
title: MultiTiddlerFiles
|
||||||
|
|
||||||
|
MultiTiddlerFiles allow multiple tiddlers to be concisely represented in a single text file.
|
||||||
|
|
||||||
|
The goals of this format are:
|
||||||
|
|
||||||
|
* To be easy to type and easy to read
|
||||||
|
* Optimised for single line strings
|
||||||
|
* To allow common fields or tags to be shared within groups of tiddlers
|
||||||
|
* To be simple to process with external tools
|
||||||
|
|
||||||
|
MultiTiddlerFiles have the extension `tids`. The file is structured as a block of shared fields followed by a blank line. The rest of the file is a sequence of comments and tiddlers. Tiddlers are specified by their title, followed by a colon, at least one space character, and then the rest of the line is the text field for the tiddler.
|
||||||
|
|
||||||
|
For axample:
|
||||||
|
|
||||||
|
```
|
||||||
|
title: $:/lingo/ControlPanel/
|
||||||
|
tags: strings
|
||||||
|
modifier: JoeBloggs
|
||||||
|
|
||||||
|
Basics/Caption: Basics
|
||||||
|
# This is a comment
|
||||||
|
Basics/Version: ~TiddlyWiki Version
|
||||||
|
```
|
||||||
|
|
||||||
|
This example defines two tiddlers, ''"""$:/lingo/ControlPanel/Basics/Caption"""'' and ''"""$:/lingo/ControlPanel/Basics/Version"""''.
|
||||||
|
|
||||||
|
If a `title` field is specified in the header then it is treated as a prefix for the individual tiddlers defined in the title.
|
Loading…
Reference in New Issue
Block a user