01-23-2012, 05:26 PM | #1 |
Member
Posts: 20
Karma: 10
Join Date: Sep 2011
Device: none
|
regex search/replace
Hey guys,
I couldn't find an answer to my question in the forums, so I figured i'd ask directly. I have an epub that i need to reformat. A like like this: <p>“Sorry.”</p> Needs to be changed to this: <p> “Sorry.” </p> I have to change all of the instances of this in my document, but i'm not sure how to add a new line break. I typed in find >& and replace it with >\n& but that clearly doesn't work. Any and all help is appreciated. Cheers. |
01-23-2012, 05:44 PM | #2 |
♫
Posts: 661
Karma: 506380
Join Date: Aug 2010
Location: Germany
Device: Kobo Aura / PB Lux 2 / Bookeen Frontlight / Kobo Mini / Nook Color
|
Sigil will convert whatever you try back to <p>“Sorry.”</p>
If you really want it that way you can't use Sigil. |
Advert | |
|
01-23-2012, 05:48 PM | #3 |
Member
Posts: 20
Karma: 10
Join Date: Sep 2011
Device: none
|
Ok. Thanks.
|
01-23-2012, 06:25 PM | #4 | |
Well trained by Cats
Posts: 30,442
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
If your intent was to add newlines to the ouput: Code:
<p><br /> “Sorry.”<br /></p> |
|
01-24-2012, 10:29 AM | #5 |
Zealot
Posts: 121
Karma: 5070
Join Date: Dec 2010
Device: none
|
|
Advert | |
|
01-27-2012, 11:43 AM | #6 |
Member
Posts: 20
Karma: 10
Join Date: Sep 2011
Device: none
|
I know that the output will show the same, however, one of the companies that we are sending our books to says that one of our books didn't pass their system test.
please see below as to the wording that they sent to me (to me it doesn't make any sense, but i've got to fix the file and send it to them): When content files in the epub contain a paragraph tag immediately followed by the entity “ there will likely be an error with the ACS server packaging. Example instance of this: <p>“Sorry.”</p> In many cases, simply following the paragraph tag with a newline will avoid the problem: <p> “Sorry.”</p> However, in other cases, both the beginning paragraph tag and the ending paragraph tag must be on their own lines: <p> “Sorry.” </p> So the best practice for avoiding this problem is to always place opening and closing paragraph tags on their own lines, in every content document. For most developers, this is a simple find and replace operation across all the content files. In cases where we have these problems, the epub file will have to be edited in this way in order to work with the ACS server and be successfully processed in our system. |
01-27-2012, 11:53 AM | #7 |
Grand Sorcerer
Posts: 28,039
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
That's just an insane requirement.
I'm afraid you'll have to accomplish it with some other regex-capable editor. And know that Sigil will just change it back again if you ever edit the epub with Sigil in the future. Last edited by DiapDealer; 01-27-2012 at 12:02 PM. |
01-27-2012, 12:01 PM | #8 |
Guru
Posts: 697
Karma: 150000
Join Date: Feb 2010
Device: none
|
As others have noted, within Sigil, even if you make the changes your client suggests, Sigil will remove the extra linefeeds when you save the file and you'll be back where you started. I don't know how to turn off this behavior.
The hard way to get around this would be, after you are completely done with everything, outside of Sigil, unzip the epub and use some other text editor to make the suggested changes. Save and re-zip. Don't load into Sigil again. But as kludge, you could avoid the occurrence of <p>“ by doing a global find & replace as follows (within Sigil): find: <p>“ replace: <p><span>“</span> or something to that effect. |
01-27-2012, 01:37 PM | #9 | |
Well trained by Cats
Posts: 30,442
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
nobody else write code like that. dump those dweebs |
|
01-27-2012, 03:52 PM | #10 |
Connoisseur
Posts: 54
Karma: 37363
Join Date: Aug 2011
Location: Istanbul
Device: EBW1150, Nook STR
|
If you can not dump them, you can use these patterns in any editor that supports regexps(e.g. Notepad++ in Windows, jEdit in Win/Mac/Linux). Just extract all files and folders from epub, open all the html/xhtml files in the editor, and use replace operation on all opened files:
Find: Code:
^(\s*)(<p[^>]*>)(.*)</p>\s*$ Code:
\1\2\n\1\3\n\1</p> |
01-28-2012, 05:14 AM | #11 |
Bookmaker & Cat Slave
Posts: 11,494
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Ducky:
Some moron is attempting to use Adobe Content Server (to encrypt the file) without knowing HOW it actually works--that's why she's getting those idiotic messages. I have lost track of the countless hours of nonsense crapola we used to experience (back when I started up) from total jackasses at "retail" eBook companies who tried to use ACS, and, not having paid the thousands of dollars to actually learn how to use it, kept getting ingestion errors and blaming the ePUBs. I've now made it our company policy that if B&N or Amazon has an intake issue, we'll address it. I won't jump through hoops for Apple's insanely bizarre error messages (oh, no! you have a MOBI ISBN typed in your file! You've MENTIONED Amazon! You set a book on the AMAZON River! We'll take you out and shoot you!) or any small-world retailer that doesn't know how to use Content Server. THAT is why she's getting this amazingly ridiculous error message. I mean, hello? You can't have an OPENING quote following an opening p tag? Moses on a Pony! And people wonder this biz has such a fast burn-through rate... Hitch |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search & Replace/Regex help!! | millertime13 | Conversion | 4 | 07-22-2011 03:40 AM |
search and replace - drops blanks in replace ? | cybmole | Conversion | 10 | 03-13-2011 04:07 AM |
regex replace??? | schuster | Conversion | 14 | 01-29-2011 10:02 AM |
RegEx find and replace | iblesq | Sigil | 1 | 01-10-2011 10:26 PM |
need regex help search and replace | schuster | Calibre | 4 | 01-10-2011 10:00 AM |