Remove Formatting... but not italics/bold.

Writing a book, Automating Document Production - Discuss your special needs here
Post Reply
ctbk
Posts: 5
Joined: Tue Aug 26, 2008 11:22 am

Remove Formatting... but not italics/bold.

Post by ctbk »

Is there a way (even a macro will be fine) to remove all formatting from some text preserving italics and bold?

I'm editing very big documents and this problem keeps coming up... Would be great to have someway to do it, I was expecting to find something in Paste Special, but no luck with that.

Thanx
OOo 3.0.X on Mac OSx Leopard
User avatar
RGB
Posts: 1456
Joined: Mon Oct 08, 2007 1:34 am

Re: Remove Formatting... but not italics/bold.

Post by RGB »

AFAIK, there is no simple way to do that. You can "tag" the text you want to preserve using regular expressions, then erase the formatting and finally change the tagged text again with regular expressions.
Something like this (example is only for italics):
1) Edit -> Find / Replace -> More options -> Check regular expressions.
2) On Find, type (.*) (with parenthesis)
3) With the cursor still on the Find box, click on Format and select Italics without changing the other options.
4) On replace type <IT>$1<IT>
Now if you click Replace (first time you must do it twice), the text in italics will be surrounded by the <IT> tags. After doing a similar process for bold, you can now delete the format selecting the text and doing Ctrl+Shift+Space.
Now, to restore the italics (thanks acknak for that!):
1) Again Find & Replace with regular expressions applied
2) (<IT>)([^<]*)\1 on Find
3) With the cursor still on Find, click on No Format
4) $2 on Replace
5) With the cursor still on Replace, click on Format and select Italic without changing the other options.
Clicking the Replace button will change the tagged text into italics.
There are two types of people: those who believe that there are two types of people and those who do not.

openSUSE Leap with KDE Plasma / LibreOffice
ctbk
Posts: 5
Joined: Tue Aug 26, 2008 11:22 am

Re: Remove Formatting... but not italics/bold.

Post by ctbk »

Yeah, that's what I thought.
I think all this could make a very useful macro.
I guess I'll have to start looking into macro programming then.

Thanks anyway.

Has anyone thought about macro-ing stuff like this altready? :D (Just in case)
OOo 3.0.X on Mac OSx Leopard
lapsed librarian
Posts: 39
Joined: Wed Jan 30, 2008 4:18 pm

Re: Remove Formatting... but not italics/bold.

Post by lapsed librarian »

I have the same problem, and got it solved (mostly). Check out my post Reformatting other people's documents
http://user.services.openoffice.org/en/ ... f=7&t=2172

In a nutshell, you set up a document with absolutely minimal formatting, then copy/paste the document you want changed into it.
OO 3.2.0 on Linux Mint 9 KDE
gsoundsgood
Posts: 5
Joined: Wed Oct 08, 2008 2:08 pm

Re: Remove Formatting... but not italics/bold.

Post by gsoundsgood »

did anyone write a macro in the meantime?

anyway, the trick I found here worked for me...
http://www.oooforum.org/forum/viewtopic.phtml?t=83738

changing all italics and bolds to some language not included in the text (eg, all italics to armenian, all bold to albanian), default all text, and then select all armenian and direct format to italics (and to your original language), select all albanian and direct format to bold (and to your original language).

so this did the trick for me, but if somebody's into writing macro, that would be great
Libreoffice on Ubuntu 11.x
Post Reply