TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
7.98k stars 1.18k forks source link

A "characters" filter that splits the input into an array of chars #3482

Closed BurningTreeC closed 5 years ago

BurningTreeC commented 5 years ago

There's a question in the google group and I've also encountered similar problems in the past, where there would be the need for a filter that splits an input title into an array of characters, so that we can modify it further

A simple filter that splits the title, like return title.split('') would already do it I think

twMat commented 5 years ago

IMO the question you link to doesn't at all require the proposal you suggest here. (I answered the fella there with a more direct solution).

That said, I think we do need a lot more string manipulation filter ops. Could you give more use cases for your proposal here?

BurningTreeC commented 5 years ago

@twMat thanks for answering

IMO the question you link to doesn't at all require the proposal you suggest here. (I answered the fella there with a more direct solution).

I wouldn't say at all in this case neither ... If we don't know the ending character of a title but want it to be red nevertheless, we need to split it off from the title, wrap it within a span or div or whatever and set its css color property to red

twMat commented 5 years ago

Fair enuf.

But, mostly from curiosity, can you give more examples of when one would need to split up the content into an array of individual characters?

BurningTreeC commented 5 years ago

@twMat I wanted to make something like spritzinc.com some time ago using the timer plugin made by @EvanBalster - that's one example for what such a filter could be useful ... another idea would be an input field that resizes with the input text-length, as I've made at outlineproto.tiddlyspot.com (the outliner view is the use-case) ... the filter used there is very primitive and not considerable here

twMat commented 5 years ago

@BurningTreeC - interesting stuff. If you haven't already, do check out @tobibeer 's split

AnthonyMuscio commented 5 years ago

The method to split is closely related to https://github.com/Jermolene/TiddlyWiki5/issues/3457 which is about string search and replace. There could be a mechanism to output the result as a single string or individual characters after the operation

Eg Input 2018-10-17

Replace "-" with "" string 20181017

Replace "-" with "" character output 2 0 1 8 1 0 1 7

And it would be nice if there was a way to accept a multiline test field and output a line at a time. This would allow detailed line by line manipulation and possible programmatic search and replace text.

AnthonyMuscio commented 5 years ago

Post Script, Line by Line manipulation would allow text sorting of content in a text field.

BurningTreeC commented 5 years ago

with 5.1.18 I'm able to split titles and text into single characters, see:

http://127.0.0.1:8095/#MacroCollection%20-%20Examples%20-%20inverse-string:%5B%5BMacroCollection%20-%20Examples%20-%20inverse-string%5D%5D%20%24%3A%2Fmacrocollection%2FBTC%2Ftext%2Finverse-string

It's a wikitext macro that splits strings into single characters ... it inverses the string, too, and puts the single characters back together, but that's just further processing

Do you think I can close this issue?

Jermolene commented 5 years ago

Hi @BurningTreeC that's a localhost URL...

AnthonyMuscio commented 5 years ago

BTC Having opened this issue and obtaining the result you requested, It would be fair for you to close it, but as a result of this request I was hoping a search and replace character or split by line. Once you correct the link as per Jeremy, I will have a look if I can use what you have created. Tony

BurningTreeC commented 5 years ago

Sorry , here's the right URL

https://burningtreec.github.io/TW5-macrocollection/#MacroCollection%20-%20Examples%20-%20inverse-string

Jermolene commented 5 years ago

As of 9b2d527, this can be done with the split operator.