05-23-2009, 03:06 AM | #1 |
Banned
Posts: 5,100
Karma: 72193
Join Date: Feb 2009
Location: South of the Border
Device: Coffin
|
Underscore to Italics in OpenOffice
I'm working on a few text that use underscores in place of italics - _italic here_ - and I was wondering if anybody knows the find/replace code to use for restoring these back to italics in Openoffice?
In word it's _(*)_ using a wild card and then a clean-up afterwards of the stray _ characters. Using 'regular expressions' in OpenOffice this same methodology just doesn't work. I know I'm doing something wrong, and that the answer is probably very simple. Thanks in advance. |
05-23-2009, 03:51 AM | #2 |
eBook Enthusiast
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Moejoe,
If you're working with text files, try the attached freeware tool, "textify". It's what I use for all my books that start off as text files. It will remove inappropriate line breaks and, if you choose the "HTML" output option, convert underscores to italics. It's a command-line tool. Just type "textify" and follow the on-screen prompts. |
Advert | |
|
05-23-2009, 04:23 AM | #3 | |
Banned
Posts: 5,100
Karma: 72193
Join Date: Feb 2009
Location: South of the Border
Device: Coffin
|
Quote:
Ta for that, it was driving me crazy trying to figure it out. |
|
05-23-2009, 04:51 AM | #4 |
Zealot
Posts: 135
Karma: 150
Join Date: Mar 2009
Device: none
|
I have used textify in another aspect and for sure this can solve your problem on italics.
|
05-23-2009, 05:13 AM | #5 |
Banned
Posts: 475
Karma: 796
Join Date: Sep 2008
Location: Honolulu
Device: Nokia 770 (fbreader)
|
If you want (pcre) regex in HTML:
Code:
Find: \_(.*?)\_ Replace: <i>$1</i> |
Advert | |
|
05-23-2009, 08:19 AM | #6 | |
Wizard
Posts: 3,454
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
so: abc abc _def def_ abc abc _def_ abc will become abc abc <i>def def_ abc abc _def</i> abc I would suggest something like Code:
[^_]* Code:
.* |
|
05-23-2009, 09:12 AM | #7 |
Wizard
Posts: 3,454
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
suggested [partial] solution in OOo Writer
Find and replace Find: _([^_]*)_ find an underscore _, followed by character that is not underscore [^_] that is being repeated as many times as possible * followed by an underscore _. Put characters between underscores into replacement group represented by $1 () Replace: $1 select: More options check "Regular expressions" click on replacement expression $1, now click on button Format and select "Italics" click "replace all" Please note: This does not work for italics spanning more than one paragraph. |
05-23-2009, 09:50 AM | #8 |
Banned
Posts: 475
Karma: 796
Join Date: Sep 2008
Location: Honolulu
Device: Nokia 770 (fbreader)
|
? is the "ungreedy" character. match would end before the second _ character.
m a r |
05-23-2009, 02:34 PM | #9 | |
Wizard
Posts: 3,454
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
|
Quote:
My favorite tool for working with text using regular expressions is gvim. gvim alone has 4 (yes, that is FOUR) different syntaxes for writing Regular expressions (and you can combine all four in a single RE, using flags (Magic, NonMagic, VeryMagic, and VeryNonMagic) The nice thing about standards is that there are so many to choose from. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenOffice to ePub export extension | eBookLuke | Writer2ePub | 206 | 12-18-2010 05:02 PM |
An OpenOffice book template | The Straven | Workshop | 14 | 05-16-2010 08:06 PM |
OpenOffice PDF Import and Hybrid Export | wallcraft | Workshop | 0 | 06-06-2008 08:15 PM |
Mac Software and Openoffice | alphaomega | Sony Reader | 8 | 08-31-2007 09:50 AM |
NeoOffice - OpenOffice.org for Mac | Chaos | Lounge | 0 | 06-06-2005 06:06 PM |