mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
More refactoring
This commit is contained in:
parent
4b3548e7bb
commit
d43efc5e18
@ -19,9 +19,6 @@ Special processing to extract embedded metadata is applied to some mimetypes.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
tiddlerInput.parseTiddlerFile = function(text,type,fields) {
|
tiddlerInput.parseTiddlerFile = function(text,type,fields) {
|
||||||
if(fields === undefined) {
|
|
||||||
var fields = {};
|
|
||||||
}
|
|
||||||
// Map extensions to mimetpyes
|
// Map extensions to mimetpyes
|
||||||
var fileExtensionMapping = tiddlerInput.fileExtensionMappings[type];
|
var fileExtensionMapping = tiddlerInput.fileExtensionMappings[type];
|
||||||
if(fileExtensionMapping)
|
if(fileExtensionMapping)
|
||||||
@ -124,8 +121,11 @@ Parse an old-style tiddler DIV. It looks like this:
|
|||||||
Note that the field attributes are HTML encoded, but that the body of the <PRE> tag is not.
|
Note that the field attributes are HTML encoded, but that the body of the <PRE> tag is not.
|
||||||
*/
|
*/
|
||||||
tiddlerInput.parseTiddlerDiv = function(text,fields) {
|
tiddlerInput.parseTiddlerDiv = function(text,fields) {
|
||||||
if(fields === undefined) {
|
var result = {};
|
||||||
var fields = {};
|
if(fields) {
|
||||||
|
for(var t in fields) {
|
||||||
|
result[t] = fields[t];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var divRegExp = /^\s*<div\s+([^>]*)>((?:.|\n)*)<\/div>\s*$/gi,
|
var divRegExp = /^\s*<div\s+([^>]*)>((?:.|\n)*)<\/div>\s*$/gi,
|
||||||
subDivRegExp = /^\s*<pre>((?:.|\n)*)<\/pre>\s*$/gi,
|
subDivRegExp = /^\s*<pre>((?:.|\n)*)<\/pre>\s*$/gi,
|
||||||
@ -134,9 +134,9 @@ tiddlerInput.parseTiddlerDiv = function(text,fields) {
|
|||||||
if(match) {
|
if(match) {
|
||||||
var subMatch = subDivRegExp.exec(match[2]); // Body of the <DIV> tag
|
var subMatch = subDivRegExp.exec(match[2]); // Body of the <DIV> tag
|
||||||
if(subMatch) {
|
if(subMatch) {
|
||||||
fields.text = subMatch[1];
|
result.text = subMatch[1];
|
||||||
} else {
|
} else {
|
||||||
fields.text = match[2];
|
result.text = match[2];
|
||||||
}
|
}
|
||||||
var attrMatch;
|
var attrMatch;
|
||||||
do {
|
do {
|
||||||
@ -144,9 +144,9 @@ tiddlerInput.parseTiddlerDiv = function(text,fields) {
|
|||||||
if(attrMatch) {
|
if(attrMatch) {
|
||||||
var name = attrMatch[1];
|
var name = attrMatch[1];
|
||||||
var value = attrMatch[2];
|
var value = attrMatch[2];
|
||||||
fields[name] = value;
|
result[name] = value;
|
||||||
}
|
}
|
||||||
} while(attrMatch);
|
} while(attrMatch);
|
||||||
}
|
}
|
||||||
return fields;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user