formatters

13 views
Skip to first unread message

Jazz

unread,
Sep 13, 2011, 7:08:44 AM9/13/11
to TiddlyWikiDev

I have written two formatters that work individually, but, one of them
fails when it is deployed with the other...
I have tried changing the regex without success. It seems the second
formatter is not loaded at all when the former one is deployed.

The following formatter works:
http://gery.tiddlyspace.com/#InsertTextInputWidgetPlugin

test here:
http://gery.tiddlyspace.com/#%5B%5Btest%20text%20input%5D%5D


The following formatter also works when on its own:
http://gery.tiddlyspace.com/#InsertTextWidgetPlugin

See test here:
http://gery.tiddlyspace.com/#%5B%5Btest%20text%5D%5D

Any idea what is wrong, is it a bug, or is it me? (normally, it's me).

PMario

unread,
Sep 13, 2011, 6:14:35 PM9/13/11
to TiddlyWikiDev
Type this into your browsers console (without the line ..)

line 1:
var f1 = config.formatters[config.formatters.findByField("name",
"InsertTextInputWidget")]

line 2
var f2 = config.formatters[config.formatters.findByField("name",
"InsertTextWidget")]

line 3
console.log('f1:', f1, 'f2:', f2)

It seems both are there :)

====
probably your object.element names are wrong.

should be:
name:
match:
termRegExp:
lookaheadRegExp:

======
I do have a question:
Why don't you use a macro for this functions. It could be one macro
with some parameters that does the whole thing.

-m

Jazz

unread,
Sep 14, 2011, 4:27:03 AM9/14/11
to TiddlyWikiDev

>
> It seems both are there :)

True, what threw me is the error message:
TypeError: this.formatter.formatters[t - 1] is undefined

That message is still showing

>
> ====
> probably your object.element names are wrong.
>
> should be:
> name:
> match:
> termRegExp:
> lookaheadRegExp:

I checked that, the parameters were wrong but modified later in the
script. Nonetheless I modified everything to those parameters from the
start which did not solve my problem.

>
> ======
> I do have a question:
> Why don't you use a macro for this functions. It could be one macro
> with some parameters that does the whole thing.

True, I ended up doing it this way because I had in mind to do some
templates and I thought this would be a better idea. In the end the
macro can do it all. However, I would not have been way too easy.

PMario

unread,
Sep 14, 2011, 9:40:50 AM9/14/11
to TiddlyWikiDev
According to similar formatters in Formatters.js

match is a string
termRegExp needs to be a regExp
lookaheadRegExp needs to be a regExp too


match: "(\\[:){3}",
string -> termRegExp: "(:\\]){3}",
string -> lookaheadRegExp: "(\\[:){3}([\\s\\S]+?)(:\\]){3}",

just a guess.
-m
Message has been deleted

Jazz

unread,
Sep 14, 2011, 11:08:22 AM9/14/11
to TiddlyWikiDev
That's probably fixed something anyway.

It is not working though, I don't think I should be spending too much
time on this any more though.

Cheers

Ben Gillies

unread,
Sep 14, 2011, 11:25:39 AM9/14/11
to tiddly...@googlegroups.com
> I have written two formatters that work individually, but, one of them
> fails when it is deployed with the other...

I'm not sure how the second formatter is supposed to render, but
adding some backslashes to your regexps seems to help somewhat (it now
at least renders _something_).

See http://sandben.tiddlyspace.com/#InsertTextInputWidgetPlugin%20InsertTextWidgetPlugin%20GeryTest


Ben

Jazz

unread,
Sep 14, 2011, 11:39:12 AM9/14/11
to TiddlyWikiDev
Yes, it does work.
What got me is that the colon character does not have to be escaped in
a regular expression.

Many thanks
Reply all
Reply to author
Forward
0 new messages