automatic conversion of file paths

3 views
Skip to first unread message

FND

unread,
Jun 8, 2007, 8:03:40 AM6/8/07
to Tiddly...@googlegroups.com
Hey all,

As discussed in a thread on [tw] this morning, here's a tiny bit of code
to automatically convert Windows file paths (e.g. "C:\MyFile.txt") as
well as network paths (e.g. "\\MyServer\MyFile.txt") to "Web-compatible"
paths in PrettyLinks:

In config.formatters, there's a section "name: 'prettyLink'".
Below the following lines ...

// Pretty bracketted link
var link = lookaheadMatch[3];

... I've added (in the actual source code, as I'm not sure how to
hijack/overwrite this):

// check for Windows file path (e.g. "C:\")
if(link.search(/^\w:\\/) != -1)
link = "file:///" + link;
// check for network path (e.g. "\\MyServer")
if(link.search(/^\\\\/) != -1)
link = "file:///" + link;

(N.B.: The regular expressions used here are not heavily tested, so this
*might* be incomplete or even buggy.)

Could this be considered for inclusion in the core?
While I don't need this myself, I guess many people do use local file
paths in their TiddlyWikis.


--F.

FND

unread,
Jun 11, 2007, 5:34:33 AM6/11/07
to Tiddly...@googlegroups.com
Patch submitted with ticket #348 (http://trac.tiddlywiki.org/ticket/348)

Please note that the regular expressions used here are not heavily

tested, so this *might* be incomplete or even buggy.


-- F.

Reply all
Reply to author
Forward
0 new messages