Currently I need some data tiddlers and found the format a bit messy. Example (broken for illustration purposes:
sharepoint_url: http://this.is.a/rather/lengthy/ url/which/tends/to/wrap/around name: shortname repository: svn://another/rather/lengthy/url/ which/tends/to/wrap/around version: 1 So I thought, why not allow a field name to stand alone on its line and join it with the next line, provided it starts with whitespace. So the above example could be written as: sharepoint_url: http://this.is.a/rather/lengthy/url/which/tends/ to/wrap/around name: shortname repository: svn://another/rather/lengthy/url/which/tends/ to/wrap/around version: 1 Still the urls wrap, but I think, this could be much more readyble, don't you agree? So I checked the code and changed it a bit. $tw.utils.parseFields = function(text,fields) { fields = fields || {}; text= text.replace(/^\s*(?:#.*)?$/mg, "").replace(/:\s*\r?\n\s+/g, ":"); text.split(/\r?\n/mg).forEach(function(line) { var p = line.indexOf(":"); if(p !== -1) { var field = line.substr(0, p).trim(), value = line.substr(p+1).trim(); fields[field] = value; } }); return fields; }; The changes I made: 1. Remove all comments in a first replace, so they need not be handled later 2. Join all lines ending with ":" with the next line, provided that line starts with whitespace 3. Remove the comment handling from the loop I haven't created a pull request for this yet, because I'd like to get your ideas about it. I also think, that maybe it is a good idea to be able to have multiline values in dictionaries. What do you think? My idea for this would be that something like this: MyDataField: this is some lengthy text with 3 lines going into "MyDataField" The value of "MyDataField" would then be: 'this is some lengthy text\nwith 3 lines going into\n"MyDataField"' -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/tiddlywikidev. For more options, visit https://groups.google.com/groups/opt_out.
