tiddler IDs (invalid with spaces)

6 views
Skip to first unread message

FND

unread,
Sep 3, 2007, 1:32:41 PM9/3/07
to Tiddly...@googlegroups.com
Even though I'm fairly certain that this has been discussed before, I
couldn't find a thread or ticket on the issue - so I'd appreciate if
someone could bring me up to speed here:

Tiddler IDs are a composed of the tiddler name and the "tiddler" prefix.
Tiddler names containing spaces are not be converted in any way, which
means the resulting ID is invalid*.

What's to stop us from converting those spaces to, say, underscores
(MediaWiki does that for page names)?
I can't think of any negative consequences resulting from such a
change - but then, I might be missing something!?
(Even if some odd user had both a "foo bar" and a "foo_bar" tiddler,
that wouldn't really cause any problems for regular users.)

By the way: If/When this is solved, we could also assign IDs as anchors
to content headings, with the ID being a combination of the tiddler ID
and the (converted) heading text:
<h1 id="tiddlerFoo_Bar_headingBar_Baz">Bar Baz</h1>
This way we could link to HREF="TW.html#tiddlerFoo_Bar_headingBar_Baz".


-- F.


* cf. http://www.w3.org/TR/html4/types.html#h-6.2

Jeremy Ruston

unread,
Sep 3, 2007, 2:09:28 PM9/3/07
to Tiddly...@googlegroups.com
Your observations are quite correct about HTML not allowing spaces in
IDs; but it turns out that it works just fine in every browser. That
allowed me to ignore the issue early on when I was getting the first
experimental versions of TW working.

I only realised the issue much later on (actually when experimenting
with the ID-based CSS selectors), and by that time there was already a
significant user base. We could have escaped the tiddler titles, but
it seemed like another nail in backwards compatibility for little
practical benefit.

So the situation at the moment is that everything works, apart from
trying to use tiddler IDs in CSS selectors - if you want to do that,
you have to make sure that the tiddler name doesn't contain spaces.

Hope that helps,

Cheers

Jeremy


--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

FND

unread,
Sep 3, 2007, 3:22:13 PM9/3/07
to Tiddly...@googlegroups.com
> it turns out that it works just fine in every browser

Yes, but there's a huge number of cruel things browsers will allow you
to do - that doesn't mean you should take advantage of such leniency
though, not if you can avoid it...
(Sorry to be a PitA here, but I can't help it.)

> So the situation at the moment is that everything works, apart from
> trying to use tiddler IDs in CSS selectors - if you want to do that,
> you have to make sure that the tiddler name doesn't contain spaces.

That's exactly the problem.
Disregarding my obsession with standard compliance, it's still very
confusing from a regular user's perspective that the CSS selector works
for some tiddlers but not for others.

So why not simply convert spaces to underscores in tiddler IDs?
That fully preserves backwards compatibility and does no harm.
...
...
Or maybe it does? I've tried patching
Story.prototype.createTiddler
by changing
var tiddlerElem = createTiddlyElement(null,"div",
this.idPrefix + title,"tiddler");
to
var tiddlerTitle = this.idPrefix + title.replace(/\s/,"_");
var tiddlerElem = createTiddlyElement(null,"div",
tiddlerTitle,"tiddler");
But for some odd reason that breaks the newTiddler macro.
Update: It also breaks when trying to open a tiddler with spaces in its
name; still not sure why though.


-- F.

Saq Imtiaz

unread,
Sep 3, 2007, 3:35:57 PM9/3/07
to Tiddly...@googlegroups.com
It will also break everyone plugin that assumes that the id for a "tiddler div" is story.idPrefix+tiddler.title

It would be nice, but backwards compatibility wins again! ;)

Cheers,
Saq

On 9/3/07, FND <Ace_...@gmx.net> wrote:



--
TiddlyThemes.com ( http://tiddlythemes.com ) : a gallery of TiddlyWiki themes.
TiddlySnip ( http://tiddlysnip.com ) : a firefox extension that turns TiddlyWiki into a scrapbook!
LewcidTW ( http://tw.lewcid.org ) : a repository of extensions for TiddlyWiki

Daniel Baird

unread,
Sep 3, 2007, 6:59:58 PM9/3/07
to Tiddly...@googlegroups.com
I think I support replacing illegal chars with underscores when making
an ID. There'd be possible clashes, but that's way better than the
css-inaccessible stuff that we get now.

You can always ship a LegacyTiddlerIdsPlugin..

;D


--
Daniel Baird
http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things That Suck)

andrewg_oz

unread,
Oct 29, 2007, 12:33:32 PM10/29/07
to TiddlyWikiDev
On Sep 4, 3:09 am, "Jeremy Ruston" <jeremy.rus...@gmail.com> wrote:
> So the situation at the moment is that everything works, apart from
> trying to use tiddler IDs in CSS selectors

That will work too if you escape the space character:

#tiddlerNew\0020Tiddler { /* ... */ }

Cheers,
Andrew

FND

unread,
Oct 29, 2007, 12:45:17 PM10/29/07
to Tiddly...@googlegroups.com

Wow, I/we had no idea!
Thanks for sharing (bonus points for your updating the wiki!).


-- F.

andrewg_oz

unread,
Oct 30, 2007, 3:28:16 AM10/30/07
to TiddlyWikiDev
I missed some important CSS syntax details. See the wiki:

http://www.tiddlywiki.org/wiki/Tiddlers#Using_Tiddler_IDs

Reply all
Reply to author
Forward
Message has been deleted
0 new messages