Make a clear text formatting button

Hello everyone, I want to make a button in the edit field that clears spaces and line breaks. Because if I copy a text from a pdf file and paste it directly, I will have extra spaces and line breaks.

I tried to make one to add spaces or line breaks, but I can’t clear them.

At the moment I haven’t found a plugin that does this. If so, please let me know. Thanks a lot.

Hi,

Did you try dragging and dropping into the tiddler editor field? Sometimes it works for me.

Regarding the line breaks, I try to work around this by selecting all text and pasting it into Word. Then I replace the line breaks with a single command. It can become messy, though. I am curious if anybody can come up with an alternative method.

You could use the codemirror edition, which has a find an replace mechanism built in.

https://tiddlywiki.com/plugins/tiddlywiki/codemirror/

Copy this text



line 1      many spaces

line 2

line 3


line x
  • Type CTRL-H … enter this text into the search box /\n/
  • ENTER
  • It asks for the the replacement string … type enter

Then it starts to ask if highlighted elements should be deleted. It’s not perfect since the first line is hidden below the dialogue.

A similar thing can be done with the spaces. … Just replace eg: 3 spaces with nothing …

I think it will be much faster as if you do it manually.

@dongrentianyu there are many ways to achieve what you want, and I have a specific solution for it however I must first ask do you really need to?

  • Once viewing the empty lines are removed and the spaces can be invisible?
  • Could you share a little example of this malformed text?

When faced with really poor formatting, I use the application Notepad++ to clean it up as it can search and replace newlines etc eg replace \n\n\n with \n but I would think its not needed in this case.

  • If it were a common need I may automate it by making a macro to read the tiddlers text field, reformat it and save into a new tiddler.

I have possibly the perfect answer but some work will be involved to explain it so I want to see if we cant find a simple way, which an example would help.

1 Like

My preferred method too!

1 Like

Thank all of you very much for your enthusiastic responses.

I think this is a critical issue that needs to be addressed. I didn’t use a code editor like word or Notepad++ to clean it up.

I find it really annoying when copying a copy of text to go back and use another program and then copy it all over again.

My current solution is to use the quicker software to work with the nodejs version of tiddlywiki, and then implement the ability to save tid text directly to the corresponding folder when editing.

剪藏 - 动作信息 - Quicker (getquicker.net)

The above solution solves 80% of my needs, but I still want to solve this problem completely in tiddlywiki.

As for the text, I copied it randomly. Because copying from a random web page or pdf file is very likely to show the above situation.

Using the codemirro plugin is really nice, but there are several problems.

The first is the problem of input method. I need to switch the input method and then can operate, which makes my editing experience is not good at all. The second one is that I need to clear line breaks and then also clear spaces. Very inconvenient. These two operations are what I often have to do, so I might as well make a macro to handle them more easily.

So I need a plugin and then a button in the edit bar where I select some text, single line or multiple lines, and then click that button so that it clears the spaces or line breaks in my selected text.

But notice that I’m not trying to generate a new tidder file. Rather, I am editing the current entry to achieve this. I don’t know if this can be done.

Or another way. When I exit the edit state, there is a button on the page that I click to clear the spaces and line breaks in it. That would be acceptable to me.

Again, thanks for the responses.