![]() |
#1 |
my parent's oops...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 492
Karma: 1477572
Join Date: Feb 2009
Device: Vx->Handera->Clie-> Axim->505->650->KPW/Aura ->L2->iOS/CBW
|
User Error in Search/Replace?
When copying paragraphs of text from #blurb to #comments, Calibre is inserting <br> tags into the html of the text. I have attached 3 images of this issue - the first is the regex being used to copy text and the other 2 show the results (normal view and html view). I am interested in *not* having Calibre insert <br> tags into the copies text.
Thanks for any thoughts. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,432
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
S & R doesn't add any text or html tags.
Your first screen capture shows that #blurb has html markup, which is copied to comments. The end of the comments matches the end of #blurb. Have you "proved" that the <br> tags are not already in #blurb? |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
my parent's oops...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 492
Karma: 1477572
Join Date: Feb 2009
Device: Vx->Handera->Clie-> Axim->505->650->KPW/Aura ->L2->iOS/CBW
|
Yes, I have "proved" that the <br> tags are not in the #blurb - if you look at the 3rd image, it shows the html for both comments and the blurb - the blurb html has no <br> whereas the text copied to the comments now has <br> tags. The <br> tags are being added by Calibre when doing the S&R.
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,432
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
It isn't search & replace that is changing it.
Experiment: appending a custom HTML comment to the standard comment
|
![]() |
![]() |
![]() |
#5 |
my parent's oops...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 492
Karma: 1477572
Join Date: Feb 2009
Device: Vx->Handera->Clie-> Axim->505->650->KPW/Aura ->L2->iOS/CBW
|
Ok, thanks so much for showing me that. I have run some tests on an empty test epub book that has "1000" Words in the #Words metadata and the Calibre workflow I have used is introducing <br> tags somehow. Can you look at what I'm doing and give your thoughts please and thanks:
Image 1: Empty epub test file with: 1000 words, no comments, test paragraphs in #blurb (no <br> tags) - I have attached it if someone wants to try this on their system Image 2: Run S&R regex to copy "Words" count to the comment field: Search field #wordcount Code:
(\d+) Code:
\1 Words Notice that the results image does not have any <br> tags anywhere Image 4: Run S&R regex to append the #blurb paragraphs to the comment field: Search field #blurb Code:
(.*) Code:
^(.*)$ Code:
\1 If I do NOT run the 1st S&R regex copying the word count into the comments, <br> tags are not introduced by the 2nd regex copying the blurb If I have an empty comments field OR have manually typed in the word count into the comments field first (ie again, not running the 1st regex) before running the 2nd regex, <br> tags are not introduced. I guess my final question would be if this is a Calibre issue or QT5/6 issue? Last edited by slantybard; 07-16-2022 at 05:58 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,432
Karma: 8012664
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I tried your experiment. Jumping to the end, I found that the problem is caused by the "1000 Words" not being enclosed in HTML.
My apologies for the length of what follows. I wrote down all the steps so I could be sure I knew what I was doing/had done. The steps I ran to discover this:
Looking at the code I thought about why calibre was adding all the stuff if the contents didn't appear to be HTML. The answer (I think) is that calibre has no idea what is in there. It must protect itself against strange and malformed html to avoid having book details get scribbled on. One could argue it is being overzealous, but Kovid arrived here after many years of experience with strange things. |
![]() |
![]() |
![]() |
#7 |
my parent's oops...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 492
Karma: 1477572
Join Date: Feb 2009
Device: Vx->Handera->Clie-> Axim->505->650->KPW/Aura ->L2->iOS/CBW
|
Thank you so much for looking into this and taking the time to explain what is happening. I really appreciate your effort!
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search & Replace Error | MerlinMama | Editor | 1 | 07-12-2017 03:36 AM |
Regex in search problems (NOT Search&Replace; the search bar) | lairdb | Calibre | 3 | 03-15-2017 07:10 PM |
"invalid group reference" error on search/replace | fodiator | Calibre | 4 | 11-01-2015 12:11 PM |
I got this error when comparing search replace results! | user743 | Editor | 0 | 06-26-2014 08:30 PM |
save multiple search/replace, or search/replace multiple ebooks | user743 | Editor | 12 | 04-12-2014 02:38 AM |