Ask Your Question
1

Converting hard line breaks to wrapped text

asked 2019-03-09 16:19:58 +0100

A. Weeks gravatar image

I get a lot of documents with paragraph breaks at the end of each line and double spaces between paragraphs. I would like to convert these to wrapped text. I can figure out how to remove ALL paragraph breaks through Regular Expressions, and I can figure out how to convert double breaks to some other character such as #, but I haven't figured out how to remove only single breaks, or convert marked double breaks from a character back to a paragraph. Ideas?

edit retag flag offensive close merge delete

6 Answers

Sort by » oldest newest most voted
1

answered 2019-03-09 18:25:57 +0100

enzotib gravatar image

updated 2019-03-09 18:26:16 +0100

There is also the AutoCorrect option explained in the following help page: https://help.libreoffice.org/6.2/en-U...

edit flag offensive delete link more
1

answered 2019-03-09 20:36:13 +0100

A. Weeks gravatar image

Yes, the originals were ASCII, and they mostly have a consistent double spacing between paragraphs. If they lacked that, I think gabix and ajlittoz would be right and I'd need an outside fix. But with it, and with Mike's help, I've been able to clean it up inside LibO.

For anyone else struggling with this, here's my step-by-step breakdown:

  1. Ctrl+H. Open "Other Options." Check the box for "Regular Expressions."

  2. find ^$, replace with # or some other meaningless character (if your text were full of, say, Twitter handles, you'd obviously want a different key)

  3. find $, replace with a single space (in case the spaces were missing from the ends of the original lines)

  4. find #, replace with \n

  5. find double spaces, replace with single space (in case the spaces were present at the ends of the original lines)

Results aren't bad. Thank you all!

edit flag offensive delete link more

Comments

A hint: you are not limited to a single-character replacements at step 2. You may also replace empty paragraphs with a string which doesn't happen in your complex document for which you cannot find a single-character replacement, like e.g. [ParagraphHere]. Then replace it back at step 4.

Mike Kaganski gravatar imageMike Kaganski ( 2019-03-09 21:02:15 +0100 )edit
0

answered 2019-03-09 17:29:57 +0100

ajlittoz gravatar image

updated 2019-03-09 17:30:14 +0100

You didn't mention the origin of your text. It smells as if it is a copy/paste from some PDF or plain ASCII file. In this case, it may be simpler to use a macro-generator outside LO Writer to do your filtering first before importing the result. Perl or m4 under Linux/Unix are your friends.

edit flag offensive delete link more
0

answered 2019-03-10 10:08:47 +0100

Grantler gravatar image

Try out AltSearch.oxt, it still works for 6.x version...

edit flag offensive delete link more
0

answered 2019-03-09 16:26:10 +0100

or convert marked double breaks from a character back to a paragraph

You have almost figured everything yourself. As mentioned on List of Regular Expressions help page:

\n in the Replace text box stands for a paragraph break that can be entered with the Enter or Return key.

edit flag offensive delete link more

Comments

Perfect. You rock

A. Weeks gravatar imageA. Weeks ( 2019-03-09 17:07:37 +0100 )edit
0

answered 2019-03-09 17:23:53 +0100

gabix gravatar image

You might want to try OOoFBTools. This extension has a lot of features to process texts, including processing line ends.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-09 16:19:58 +0100

Seen: 249 times

Last updated: Mar 10