Building a filter from parts, unwanted spaces

79 views
Skip to first unread message

TonyM

unread,
Jul 13, 2018, 4:12:19 AM7/13/18
to TiddlyWiki
Folks,

I have had this problem in the past but cant find the original solution.

The following is returned from a trail of listwidgets, buttons and reveals

These values are sourced from two state tiddlers yet returns with a leading space between the two parts and a trailng space.

" [enlist{!!edit-fields-list}] sort[]] "

If anyone can tell me how to avoid these spaces or remove them please help. They are not in the code but an artefact.

Thank in advance
Tony

Jed Carty

unread,
Jul 13, 2018, 6:22:31 AM7/13/18
to TiddlyWiki
I think that normally comes from line breaks in your code that normally shouldn't do anything. Something like

<$list filter=blah>
<$reveal blah blah blah>
something
</$reveal>
</$list>

may give some extra whitespace that you can sometimes remove by doing this:

<$list filter=blah><$reveal blah blah blah>
something
</$reveal></$list>

I have never been able to clearly remember which parts add whitespace and which don't so it may take some tinkering to get right.

Hopefully that helps.

Mark S.

unread,
Jul 13, 2018, 8:49:49 AM7/13/18
to TiddlyWiki
Undocumented, secret-handshake structures is another reason why I would prefer to code in javascript.

-- Mark

TonyM

unread,
Jul 13, 2018, 8:57:02 PM7/13/18
to TiddlyWiki
Jed,

Thanks for the suggestions, I have worked through the code and there are little or no opportunities for a break to sneak in to the code. But I will review it with fresh eyes, I will also see if I can make a macro that removes the spaces because I am not keen to add more complexity into the code.

Thanks
Tony

TonyM

unread,
Jul 13, 2018, 9:01:53 PM7/13/18
to TiddlyWiki
Mark,

I think this is a bug I stumbled upon previously. Is java script free of bugs?

As someone who is yet to learn java-script properly, it is the shortest path for me to use wikitext.

But how would you reproduce the list filter structure of tiddlywiki in javascript, I expect it could be quite poor at replacing this structure.

Just curiouse

Regards
Tony

Mark S.

unread,
Jul 14, 2018, 6:24:15 PM7/14/18
to TiddlyWiki
I think this is a bug I stumbled upon previously. Is java script free of bugs?

Javascript gets pounded on by millions (billions?) of users every day. In the vein of "Gödel, Escher, Bach", there's bound to be some bugs in there. The question is, how long does it take before you encounter an actual bug? In the case of TW5 and spacing problems, I have code from 4 years ago where I couldn't get the spacing right and just gave up on it. Having to squeeze out all the space in order to make something work then makes WikiText harder to read than javascript.

As someone who is yet to learn java-script properly, it is the shortest path for me to use wikitext.

It's just a simplified c-style language. A reference book on my shelf is from 1996, only 8.5* x 5.5" x 1/2 inch thick, and mostly still relevant today. It's not like Java with tightly maintained data types.

But how would you reproduce the list filter structure of tiddlywiki in javascript, I expect it could be quite poor at replacing this structure.


JS has all the control structures that you would expect from a modern language, including switch, while, and for. An array data structure, object modeling, text manipulation and a full math library. Think how often we've needed or wanted some type of numerical control in TW5. To do anything involving basic arithmetic, you have to use someone's 3rd party kit, because there's nothing relating to numbers as filter operators beyond very simple functionality.

-- Mark


@TiddlyTweeter

unread,
Jul 14, 2018, 6:57:09 PM7/14/18
to TiddlyWiki
I'm not a JavaScript programmer but it's possible in TW to get quite raw with it to good effect sometimes. But it's mainly limited to the pre-parser you get that freedom. I really like and use a lot BJ's Flexity plugin that let's me use standard JS regular expressions in TW without the indirection needed if you do it the normal way (character classes are really complicated). I do think that the "layering" in TW has some consequences that are not well documented. "Spacing" is a perennial issue that comes up. The \whitespace pragma is an attempt to solve some of them. It's just odd that the layout of code should effect the layout of results.
Reply all
Reply to author
Forward
0 new messages