Left over artefact in "wikiLink" formatter

4 views
Skip to first unread message

Martin Budden

unread,
May 14, 2006, 4:05:25 PM5/14/06
to TiddlyWikiDev
Jeremy,

The item:

badPrefix: config.textPrimitives.anyLetter,

in the "wikiLink" formatter is never used. (I guess it's a leftover
from the wikifier hunker-down coding session.)

If you change it you might also like to do the following (minor)
optimisation at the same time:

name: "wikiLink",
match: config.textPrimitives.wikiLink,
badPrefix: config.textPrimitives.anyLetter,
handler: function(w)
{
var preRegExp = new RegExp(config.textPrimitives.anyLetter,"mg");
var preMatch = null;
if(w.matchStart > 0)
{
preRegExp.lastIndex = w.matchStart-1;
preMatch = preRegExp.exec(w.source);
}
...
}

can be changed to:

name: "wikiLink",
match: config.textPrimitives.wikiLink,
handler: function(w)
{
var preMatch = null;
if(w.matchStart > 0)
{
var preRegExp = new RegExp(config.textPrimitives.anyLetter,"mg");
preRegExp.lastIndex = w.matchStart-1;
preMatch = preRegExp.exec(w.source);
}
...
}

The preRegExp regular expression does not need to be created unless it
is used. Okay so this doesn't buy much, but it is free.

Martin

Jeremy Ruston

unread,
May 15, 2006, 4:59:34 AM5/15/06
to Tiddly...@googlegroups.com
Goodness, you're turning over stones that no ones ever touched before :)

I think actually that what I meant to write was this (incorporating
your optimisation):

{


name: "wikiLink",
match: config.textPrimitives.wikiLink,
badPrefix: config.textPrimitives.anyLetter,
handler: function(w)
{

var preMatch = null;
if(w.matchStart > 0)
{

var preRegExp = new RegExp(badPrefix,"mg");


preRegExp.lastIndex = w.matchStart-1;
preMatch = preRegExp.exec(w.source);
}
...

The idea being that people (apparently) need to be able to override
the badPrefix value to get sensible wikilinks in some languages.

Many thanks,

Jeremy


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

Martin Budden

unread,
May 15, 2006, 2:04:19 PM5/15/06
to TiddlyWikiDev
I'm not so sure:

This is testing that the character before a tentative wikilink is not a
character that is allowed in the wikilink. So:

aCamelCase is not a wikilink, since the a is "anyLetter"

in (CamelCase), CamelCase is matched as a wikilink.

in @CamelCase, CamelCase is again matched.

I think that, by definition, the prematch character must be in
config.texPrimitives.anyLetter.

Localisation is achieved by changing the contents of
config.textPrimitives.anyLetter, and the addition of badPrefix is
unnecessary.

Martin

Martin Budden

unread,
May 15, 2006, 2:26:20 PM5/15/06
to TiddlyWikiDev
Turning over stones...

TiddlyWiki is a rare beast: it's complex enough to be interesting (as
well as being really useful), yet it is simple enough that it can be
completely understood. It's also well-structured which makes the code a
pleasure to read.

So I'm doing precisely that: trying to understand it fully, and at the
same time reading every line of code. Whenever I find a quirk, I'll
make a posting (but there aren't many..).

Martin

Simon Baird

unread,
May 15, 2006, 7:31:30 PM5/15/06
to Tiddly...@googlegroups.com
At least for me most of the the wikifier engine code is too hard to get my head around. I'm glad there's someone poking and prodding it. So keep turning those stones.. :)
Simon.

 
--
Simon Baird <simon...@gmail.com>

Jeremy Ruston

unread,
May 16, 2006, 8:55:35 AM5/16/06
to Tiddly...@googlegroups.com
> So I'm doing precisely that: trying to understand it fully, and at the
> same time reading every line of code. Whenever I find a quirk, I'll
> make a posting (but there aren't many..).

I've got a little rant about that: I cut my teeth on a British home
computer called the BBC Micro. It was 6502 based with 32KB RAM and
32KB ROM, and a bunch of quite sophisticated custom hardware. The
beauty of that machine as a learning environment was that as a 15 year
old it took a relatively small slog to get to the point where I
intimately understood essentially everything about how it worked - at
least from the software perspective. By that I mean that I knew the
purpose of every shared memory location, I'd disassembled the BASIC
ROM to figure out how floating point arithmetic worked, I'd twiddled
bits to figure out the custom hardware and what it did, etc. - and I
could write 6502 assembly language directly in hex.

That level of complete understanding gave me a really invigorating
sense of being in control of the machine, of being inside the minds of
it's designers. At the risk of sounding florid, I felt that the
machine was exposed in all it's naked glory in front of me with
nothing hidden, nothing veiled by ignorance. And of course this
doesn't just apply to me - I'm part of a generation of geeks that had
the same advantage, whether it was with the BBC Micro or the Apple ][.

And of course, the point of the rant is that for a 15 year old today
the idea of being able to understand the entirity of a PC (or Mac) and
all of it's system software is utterly absurd. It's the difference
between a 19th century scholar who might be able to flatter themselves
that they had a useful working knowledge of all the sciences and a
scientist working today who must necessarily choose areas of
specialisation and remain ignorant of 95% of the detailed scientific
knowledge of their day.

Anyway, I love the idea that TW can be an arena for learning, and I'm
very grateful for your insights.

Cheers

Jeremy.

Martin Budden

unread,
May 17, 2006, 3:18:49 PM5/17/06
to TiddlyWikiDev
32K? Luxury!

I dreamed of 32K...

(Sorry I couldn't resist that.)

It seems we were on parallel paths. I started off with a Science of
Cambridge MK14 (512 bytes (sic) ROM, 512 bytes of RAM, which I upgraded
to 1K of RAM). The MK14 used an SC/MP microprocessor which had a small
but quirky instruction set, which I could keep in my head and write
directly in hex. I then graduated to a Compukit UK101 which was 6502
based. I had an assembler for this, but it took so long to load (from
tape) that I tended to machine code directly on it as well, although I
used a crib sheet (but the entire instruction set fitted easily on a
side of A4). I thought the 6502 instruction set was elegant, and was a
pleasure to program.

I have some sympathy with your rant, but on the other hand I'm an
optimist and I think there are plenty of interesting areas a 15 year
old can get involved in today. But I agree that there are not that many
where something can be understood in its entirity.

And that reminds me - another reason I find TiddlyWiki interesting is
that its an environement where code size and code speed is important -
there seem to be fewer and fewer of these.

Martin

Jeremy Ruston

unread,
May 17, 2006, 3:51:34 PM5/17/06
to Tiddly...@googlegroups.com
Oh, funnily enough I also had an MK14 (only early computer I've still
got until my Amiga 500), it was the first machine I ever programmed -
the bit that I remember vividly was that the SC/MP 8060 didn't have a
return stack, but rather you had to manually push and pop the program
counter. At the time it got a lot of poor press for that, but of
course 15 years later it became a standard aspect of RISC
architectures. But I went on to the ZX80 and from there to the BBC
Micro. I used to lust after the UK101, it seemed a wonderfully
sophisticated thing to me, despite having no case.

Cheers

Jeremy

Daniel Baird

unread,
May 17, 2006, 7:28:42 PM5/17/06
to Tiddly...@googlegroups.com

I had to write my early programs by twisting the wires together!  And that was before they invented 0s -- I had to do it all with just 1s!

Ok, enough of that joke.  It was a Commodore 64 for me.  Showing our ages, aren't we..

;D

(TiddlyW;nks! :: Whiteboard Koala :: Blog :: Things That Suck)

Eric Shulman

unread,
May 17, 2006, 8:56:56 PM5/17/06
to TiddlyWikiDev

Daniel Baird wrote:
> I had to write my early programs by twisting the wires together! And that
> was before they invented 0s -- I had to do it all with just 1s!
>
> Ok, enough of that joke. It was a Commodore 64 for me. Showing our ages,
> aren't we..

I started out 30 years ago on DEC PDP KA10 running RSTS/E: a 16K
partioned runtime for interpreted BASIC, accessed via acoustic dialup
modem at 110 baud. Yes, that's right, 110 bits per second! I could
even *whistle* the right pitches into the phone and get the remote
system to send back a 'login banner' (unfortunately, I never could
manage to whistle my username/password to actually log in :-)

...and don't forget the IBM 029 punch cards ("how do you erase a
hole?") and ASR33 TeleTypes (with paper-tape punch)... piles and piles
of 'chaf' to toss around ... what a mess! ... and the card
sorter/collator was programmed with 'punch board' wiring ("hey... does
anyone have any more green wires?... No... Use two yellows and an
empty connector in the common block as a bridge!...")

I learned EBCDIC, ALGOL-60, Hollerith codes, DEC 6-bit character sets,
and the startup sequence for the PDP-8, which had a 96-byte "boot
loader" program that was entered via a bank of 16 switches on the front
panel of the system. Each switch was one bit of a 2-byte instruction
word. Set all 16 switches.. press the 'enter' switch... do it again..
press enter... 48 times... just to get the thing to start reading a
spool of punched paper tape with the rest of the 'system exec'...

ah... such were the days of yore...

-e

Reply all
Reply to author
Forward
0 new messages