[TW5] How to remove carriage returns in selected tiddly text?

67 views
Skip to first unread message

Chuck R.

unread,
Dec 14, 2019, 10:13:56 AM12/14/19
to TiddlyWiki
Using Windows 10, with TW5 on tiddlyspot.com, using Firefox browser, using TW5 language, TW v5.1.19

Sometimes when I copy part of an abstract from a web page into a tiddler there will be embedded carriage returns or line feeds. So I paste the text into a liste item (prefixed with '# ') and where there is a CRLF the text breaks out of the list item to form a new paragraph.

Is there a way in the TW5 editor to select text and remove CRLF from that text so all text from a list item will be in that list item? Or do I have to paste the text into a text editor, join the lines, and paste it back into TW5?

Thank you.

Eric Shulman

unread,
Dec 14, 2019, 11:49:00 AM12/14/19
to TiddlyWiki
On Saturday, December 14, 2019 at 7:13:56 AM UTC-8, Chuck R. wrote:
Sometimes when I copy part of an abstract from a web page into a tiddler there will be embedded carriage returns or line feeds. So I paste the text into a liste item (prefixed with '# ') and where there is a CRLF the text breaks out of the list item to form a new paragraph.   Is there a way in the TW5 editor to select text and remove CRLF from that text so all text from a list item will be in that list item? Or do I have to paste the text into a text editor, join the lines, and paste it back into TW5?

You don't need to remove the carriage returns or line feeds!  There's a little trick that keeps the content from "falling out" of the bullet (* or #) syntax:


Summary: If you enclose the pasted content between *tripled* quotes ("""), the line breaks will not be parsed, and they will remain as literal linebreaks

For example:
#first item
#"""second item
this is test
that has newlines
in it
some are just one CR
or LF

and some are doubled, or have more,


like
this."""
# third item

enjoy,
-e

Chuck R.

unread,
Dec 14, 2019, 12:28:35 PM12/14/19
to TiddlyWiki
Thanks Eric but I don't want to keep the literal line breaks in a list item, I want the whole list item to rewrap to the size of the browser window.

Eric Shulman

unread,
Dec 14, 2019, 1:08:32 PM12/14/19
to TiddlyWiki
On Saturday, December 14, 2019 at 9:28:35 AM UTC-8, Chuck R. wrote:
Thanks Eric but I don't want to keep the literal line breaks in a list item, I want the whole list item to rewrap to the size of the browser window.

oh... in that case... here's a quick method for converting newlines to spaces without needing an external text editor

input tiddler: <$edit-text tiddler="$:/temp/input" tag="input" default=""/>

original content
:
<pre>
<$text text={{{ [title{$:/temp/input}get[text]] }}} />
</pre>

output tiddler: <$edit-text tiddler="$:/
temp/output" tag="input" default=""/>
<$button> change linebreaks to spaces
<$action-setfield $tiddler={{$:/temp/output}} text={{{ [title{$:/temp/input}get[text]splitregexp[\n]join[ ]] }}} />
</$button>

result:
<pre>
<$text text={{{ [title{$:/temp/output}get[text]] }}} />
</pre>

It's not the most elegant solution, but it should get you started...

enjoy,
-e


Chuck R.

unread,
Dec 18, 2019, 8:28:07 AM12/18/19
to TiddlyWiki
Thank you Eric, but I'm not familiar with using macros or widgets. How do I use the code you gave me?


Reply all
Reply to author
Forward
0 new messages