Indirectly inspirted by Lines containing only whitespace - a continuing annoyance.
- I am seeking ideas, to solve this problem;
Another problem with unwanted lines, blank or otherwise includes this example, pasting from ChatGPT
Intro
item1 paragraph
item2 paragraph
item3 paragraph
conclusion
If I want to apply bullets to this with the editor toolbar button, I get.
Intro
# item1 paragraph
#
# item2 paragraph
#
# item3 paragraph
conclusion
- Can you guess why its no good?, paste into tiddlywiki.com
- Now I need to delete the blank lines between every item before applying numbers or bullets, sometimes a long list.
When I would be happy with;
Intro
# item1 paragraph
# item2 paragraph
# item3 paragraph
conclusion
Looking at the buttons like $:/core/ui/EditorToolbar/list-number I can’t make out a way to implement this or $:/core/ui/EditorToolbar/list-bullet to ignore empty lines;
Anyone have any idea how I may achieve this?
IMO it’s a feature to be able to “prepare” empty lines for input.
- We can mark 5 empty lines and give them the prefix needed.
- Then add the text you want.
It would be possible to create a plugin, but I’m pretty sure we should not change the default behaviour after all that time.
If a plugin would handle that it needs to be configurable. … My custom-markup plugin is able to handle it, in a slightly different way. But it will need a bit of a configuration and it’s not really intuitive.
I think the custom-markup plugin contains some useful additions to the tm-edit-text-operation messages, but they are a bit specific at the moment.
I was thinking about extracting those functions into their own plugin, but I didn’t have the time to do so.
Of course, this kind of problem affects not just TiddlyWiki, but many cross-application transfers of information, such as pasting from certain email messages; the inverse problem (extra line breaks) affects most copy operations from PDF files, etc.
I’m eager to see TiddlyWiki-specific solutions.
Meanwhile, in case anyone reading this thread is a mac user, I highly recommend TCleaner, a system utility with configurable clipboard transformations. It facilitates everything from basic rewrapping, trimming and stripping, smart/dumb prime/quote swaps, through upper-lower-case transformations, to regex custom replacements.
My aforementioned dot paragraph works well for this, except in the case of the subject of this topic. For more advanced users Marios custom-markup plugin can do that and more.
- All I am asking for is a mechanism to create the editor toolbar buttons. I may try asking ChatGPT?
There is some docs how to create an editor toolbar button with a keyboard-shortcut.
The missing thing is an eg: “toggle-prefix” tm-edit-text-operation parameter, which has to be javascript, since it’s not possible to manipulate text-area selections with wikitext. …
And I think it will never be, because it is not possible to manipulate it within JS code too. …
As soon as a button is clicked the selection in a text-area-widget goes away. We need to open the text-area within an <iframe> element to be able to maintain and manipulate the text selection.
- Agree, this would be a smart approach,
- But I am confident it can be done. For example capture the selection in another tiddler, parse each line
splitregexp[\n], testing each for non whitespace, and prefix only those lines.
- This however requires a quite involved set of code.
- I suppose I was hoping someone had a simpler method.
Perhaps looking at the code behind the various tm-edit-text-operation’s code cloning and hacking the prefix to operate only on non-blank lines.
Or even creating a ffffunction (the fff helps remind me they are filters), in tw 5.3.x functions or operator in js to operate only on non-blankank lines, a bit like your removal solution.
- Although I don’t yet know how it works.
- I have done this, first use save-selection message within tm-edit-text-operation, then manipulate, then insert-text the result. Replacing the selection.