![]() |
Quote:
|
Quote:
At least the Windows GNU sed port requires that both the .html files and the sed script be utf8 files without byte order marks. AFAIK, .html files created by Sigil are automatically saved without BOMs. I.e. you only have to make sure that the sed script doesn't have one either. Quote:
But you are of course right, Sigil doesn't do sed. That's when even rudimentary sed or Perl skills come in handy. |
Quote:
|
Quote:
|
Thanks all for the lesson. :)
|
Hi! I'm looking for an expression that erase "- " but not " - ".
(example: sim- ple, not: word - word). Could somebody help me?? |
Quote:
replace: \1\2 only if surrounded by lowercase letters BUT :eek: it also gets legitimate hyphenated words |
Quote:
Find: (?<!\s)-\s Or: \w\K-\s Replace: <empty/blank> Please test first, and do keep in mind that there's many situations in normal written text where what you're looking for will (and should) occur. I certainly wouldn't suggest using "Replace all" but it may help you narrow down the occurrences enough where you can sign off on each and every replacement. |
Help! I am clueless about regex. I have a Word document I saved as HTML Filtered (sure didn't seem to filter much!). I imported it into Calibre and converted to ePub. Between MSO and Calibre I ended up with over 41,000 :( rows in the CSS. Every paragraph has its own class. Examples:
<p class="MsoNormal79"><span class="calibre14"> <p class="MsoNormal80"><span class="calibre20"> <p class="MsoNormal81"><span class="calibre20"> <p class="MsoNormal82"><span class="calibre17"> I want them all to say: <p class="paragraphtext"> Can I put something in find to replace them all at once?:help: Karen |
You could very well end up with a disaster if you're not careful. I would start with the paragraphs first as spans can get a bit hairy.
If you're absolutely sure that you want to change everything that has a class name of "MsoNormalXX" (X being numerals) to "paragraphtext", then: Find: <p class="MsoNormal\d+"> Replace: <p class="paragraphtext"> Make sure you have good backups in case things don't turn out the way you've planned. |
Don't use Calibre to clean up the filtered HTML. Either do it manually in Sigil or use a program/macro to do it.
Conversion to ePUB in Calibre will cause big changes in your styles. Further more, it is not necessary, since Sigil can import HTML without issues. |
Quote:
Karen |
Quote:
But, I'll keep working on it and eventually I will have a decent looking, if not perfect, eBook! Karen |
Quote:
It didn't do what it was intended to do?... or it didn't do what you wanted/expected it to do? There's a difference. ;) It certainly should have done what I said it would do... if you had the ePub open in Sigil, in Code View(an html file), with the F&R widget open (and in Regex mode) and set to "All HTML Files". |
Suppressing <br /> tags only in "body text" style.
Could there be a way to destroy the soft hyphens only when they are included in a "body text" paragraph? Rationale: After using a new (and not perfect) OCR , I found that my recognized text was interspersed with a lot of <br /> tags (soft hyphens?). I usually insert the html file in OpenOffice and clean all formatting to begin with. Even this way, I realized that these resilient tags survived. It is not that bad. Some poems or songs are thus nicely transcribed. On the other hand, I have to clean these tags for many standard paragraphs of text. Sigil provides a simple way out. The user has a choice either cleaning every one of them, good and bad, or selectively and patiently suppress the useless tags... There could a better one. Give your songs or poems their own style, keep standard text in its "body text" class and then launch the following Regex... |
<br />'s are not soft-hyphens.... just to be clear. ;)
Quote:
If there's only one occurrence of the <br /> tag inside a paragraph, this expression should find it (only inside p tags of the class "body-text"): Code:
<p class="body-text">(?!</p>).*\K<br[^>]*?/>The following expression should match the first occurrence (if there's more than one) of a <br /> tag inside p tags of the class "body-text". Code:
(?U)<p class="body-text">(?!</p>).*\K<br[^>]*?/>It's certainly not ideal, but if you have multiple <br /> tags inside the targeted paragraph (class name "body-text"), you could conceivably run one or the other of these "Replace All" expressions multiple times until the search no longer matches anything. Still quicker than stepping through each occurrence (and will ignore all other p classes), though. |
@DiapDealer
Thanks very much for your reply. I will put it soon to work. Do you think it is possible to join your two commands with a kind of AND/OR link so that it would destroy the tags two by two or be happy with one? Thanks for the vocabulary. I was not sure about it. Now I know. |
Quote:
|
@DiapDealer
I am very pleased to report full success of your Regex ( I used the first one) which deleted successively in seven busy rounds: 53/22/7/5/2/2/2 occurrences of the <br /> tag. :thumbsup: :thanks: This is only the top of the iceberg, because on the odt I previously manually destroyed probably about over one hundred. I did not know then I would use your regex. For information, this is the styles break-up of the test EPUB (classes only): Spoiler:
|
Quote:
|
reverse linking time consuming woes
<a href="../Text/notes.html#scrip1" id="backscrip1">This text is a link</a>
The above is some code in my file that I use to reverse link, or tag/anchor, whatever they call it. You click on a link in one file (in this case clicking on the text "This text is a link" would take you to the "../Text/notes.html file, where another link is designated as "scrip1", with the previous link "This text is a link" was designated as "backscrip1". So they go back and forth. When there are hundreds of reverse links, it take me a short time to list the main code ie... <a href="../Text/scriptures.html#scrip1" id="backscrip1">This text is a link</a> <a href="../Text/scriptures.html#scrip1" id="backscrip1">This text is a link</a> <a href="../Text/scriptures.html#scrip1" id="backscrip1">This text is a link</a> <a href="../Text/scriptures.html#scrip1" id="backscrip1">This text is a link</a> <a href="../Text/scriptures.html#scrip1" id="backscrip1">This text is a link</a> but now I have to go back and change the second occurrence of the linking code to "2" then "3" then "4", ie... <a href="../Text/scriptures.html#scrip1" id="backscrip1">This text is a link</a> <a href="../Text/scriptures.html#scrip2" id="backscrip2">This text is a link</a> <a href="../Text/scriptures.html#scrip3" id="backscrip3">This text is a link</a> <a href="../Text/scriptures.html#scrip4" id="backscrip4">This text is a link</a> ....you get the idea. Is there a way to use the find and replace in such a way that it would search for this code and bump up the number for each occurrence, so I won't have to manually find each one and put in each number separately myself? :thanks: |
Quote:
|
I was afraid of that. I guess the best thing would be to save it as a template and insert the text, but that still entails manually inserting each occurrence. Is there a quicker way of doing such a task that I just am not aware of yet? Thanks for the consideration.
|
I don't know about Sigil, but this is what I do in vim:
I use a special symbol (¬, |, ¦ are useful for this) where I want the consecutive numbers: Code:
<a href="../Text/scriptures.html#scrip¬" id="backscrip¬">This text is a link</a>Code:
: let n=1 | g/¬/s/¬/\=n/g | let n+=1 |
Omg are you serious? I will have to give it a go! So how would I go about getting the code into Sigil afterward? That is the only way I know to convert it into epub.
|
An ePub is a zip, so just extract the file you want to modify, change it with vim (or your preferred editor), and zip it back.
|
Doh! I should have thunk of that! Thanks!! By the way I got to the end of my first tutorial with Vim. I can now say I performed my first "yank and put". Pretty neat editor. I have tried to make the ¬ character in Vim but it doesn't work as it does in this message. (alt-170). Can you tell me how to make it in Vim?
update: well it works as you said, sweet! I just copied the "¬" but I still would like to learn how to make it in Vim. Thanks. |
I use ¬ because I can easily input it with my keyboard layout (Spanish): AltGr+6. Use whatever symbol you can find in your keyboard that's not used elsewhere: #, ~, @...
|
Quote:
<ctrl-v>uac<esc> In human language, this means: hold down the "ctrl" key and press v, release both, type uac, then tap the "esc" key. The "ctrl-v" says a multi-keystroke character follows, "u" means it is UTF, "ac" is the hex code for the "not" symbol, and "escape" ends the sequence. Having said all that, it is a lot easier to just use some other seldom-used character that appears on your keyboard, such as "@", instead of the "not" character. |
Thanks, you are right, simple is better :)
|
First thanks for everyones help here. While I haven't posted for help the answers to other peoples problems has helped me as well when I had similar questions. however I have a question that I don't see an answer to.
I am trying to remove a start and end div tag. These span an entire chapter. Code:
<body>FIND Code:
<div class="story" id="part-\d+">(.*?)</div>Code:
<div class="story" id="part-\d+">(.*)</div>EDIT: Ok it seems that the regex was fine, it just doesn't work in 0.5.902 but does work in 0.5.3 which I don't like using much for finding/replacing because over half the time I get left with a literal \1 instead of the actual text. Which of course I have to UNDO, FIND, REPLACE for each. Easy enough when it's a large block of text, not so easy when it's a word or sentence forcing me to do another FIND for any 1< instances. A REPLACE ALL is just a nightmare if you don't have a backup. |
Quote:
Code:
<div class="story" id="part-[0-9]+">(.*?)</div> |
Quote:
|
Help with regex and chapters
I have a book I'm fixing where the chapters are named:
Code:
<p class="calibre4">1</p>How can I change these occurences with, for instance Code:
<h3>Chapter 1</h3>I've tried all the combinations I know of but can't seem to get it done. Many thanks ! Paul |
I suck at regular expressions, but this should work in Sigil 0.5.3:
Find: <p class="calibre4">(\d+)</p> Replace: <h3>Chapter \1</h3> |
@Danger: In most regex flavors dot(.) does not match newline characters by default. Your case requires the dot to match newlines. In Sigil either select Regex Dotall from the mode listbox(beta version does not have that mode iirc), or append (?s) in front of your find pattern. Example:
Code:
(?s)<div class="story" id="part-\d+">(.*)</div> |
Quote:
It definitely worked ! :thumbsup: |
Quote:
|
Quote:
Code:
(?sm)<div class="story" id="part-\d+">(.*?)</div> |
I would like to change the capitalization a particular phrase across a book e.g. chapter one to Chapter One. I can detect the instances using (\D+) (\D+) and know the replacement would be \1 \2, but not how to change the capitalization.
|
| All times are GMT -4. The time now is 07:52 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.