Page 1 of 1

Remove Formatting... but not italics/bold.

Posted: Thu Aug 28, 2008 11:55 am
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

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

Posted: Thu Aug 28, 2008 12:55 pm
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.

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

Posted: Thu Aug 28, 2008 2:43 pm
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)

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

Posted: Wed Sep 03, 2008 1:27 pm
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.

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

Posted: Fri Jun 17, 2011 9:40 am
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