Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 05-23-2009, 03:06 AM   #1
Moejoe
Banned
Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.
 
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.
Moejoe is offline   Reply With Quote
Old 05-23-2009, 03:51 AM   #2
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
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.
Attached Files
File Type: zip Textify.zip (44.1 KB, 493 views)
HarryT is offline   Reply With Quote
Advert
Old 05-23-2009, 04:23 AM   #3
Moejoe
Banned
Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.Moejoe did not drink the Kool Aid.
 
Posts: 5,100
Karma: 72193
Join Date: Feb 2009
Location: South of the Border
Device: Coffin
Quote:
Originally Posted by HarryT View Post
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.

Ta for that, it was driving me crazy trying to figure it out.
Moejoe is offline   Reply With Quote
Old 05-23-2009, 04:51 AM   #4
Jill75
Zealot
Jill75 doesn't litterJill75 doesn't litter
 
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.
Jill75 is offline   Reply With Quote
Old 05-23-2009, 05:13 AM   #5
rogue_ronin
Banned
rogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-books
 
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>
m a r
rogue_ronin is offline   Reply With Quote
Advert
Old 05-23-2009, 08:19 AM   #6
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,447
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
Quote:
Originally Posted by rogue_ronin View Post
If you want (pcre) regex in HTML:
Code:
Find: \_(.*?)\_
Replace: <i>$1</i>
m a r
.* would eat up also all underscores, because the star quantifier is "greedy"
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:
[^_]*
instead of
Code:
.*
kacir is offline   Reply With Quote
Old 05-23-2009, 09:12 AM   #7
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,447
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.
kacir is offline   Reply With Quote
Old 05-23-2009, 09:50 AM   #8
rogue_ronin
Banned
rogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-booksrogue_ronin has learned how to read e-books
 
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
rogue_ronin is offline   Reply With Quote
Old 05-23-2009, 02:34 PM   #9
kacir
Wizard
kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.kacir ought to be getting tired of karma fortunes by now.
 
kacir's Avatar
 
Posts: 3,447
Karma: 10484861
Join Date: May 2006
Device: PocketBook 360, before it was Sony Reader, cassiopeia A-20
Quote:
Originally Posted by rogue_ronin View Post
? is the "ungreedy" character. match would end before the second _ character.

m a r
Sorry for not recognizing an ungreedy quantifier *? in Perl syntax.

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.
kacir is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 01:13 PM.


MobileRead.com is a privately owned, operated and funded community.