11-30-2015, 04:44 PM | #1 |
Enthusiast
Posts: 31
Karma: 12920
Join Date: Nov 2014
Device: Voyage 5.8.9.2
|
Metadata comments formatting?
Hello everyone, is there a way to disable the formatting in the metadata comments section?
Currently I clear all formatting but I'm usually left with something like: <p class="description">blah,blah,blah</p> or: <p>blah,blah,blah</p> I'd like to get rid of all that and just have: blah,blah,blah Also, is there a way to disable the formatting toolbar in the comments section all together? I'm trying to have a "clean" <dc:description> in the epubs content.opf file |
11-30-2015, 05:28 PM | #2 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
No, calibre automatically adds html formatting. The minimum you can get away with is a set of p tags.
But if you don't modify the description, calibre will not mess around with it. That's the only way to get plaintext comments. |
Advert | |
|
11-30-2015, 05:35 PM | #3 |
Enthusiast
Posts: 31
Karma: 12920
Join Date: Nov 2014
Device: Voyage 5.8.9.2
|
Oh, ok, thanks.
Does Calibre also add them during format conversion? |
11-30-2015, 06:23 PM | #4 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
No, it's part of the metadata editing I am pretty sure.
calibre won't modify your metadata on its own, but it does have its own rules about how you can update it. Namely, it will auto-htmlize any changed metadata you modify the book record with. |
11-30-2015, 08:26 PM | #5 |
Guru
Posts: 631
Karma: 7544080
Join Date: Apr 2013
Location: Berlin
Device: PRS 350, Kobo Aura
|
You could modify calibre itself or make a plugin. I think calibre runs your description only through some function, likely names txt2html or something like that. Shouldn't be that hard, but I don't know, if this could negatively impact for example the fetching of metadata.
|
Advert | |
|
11-30-2015, 08:53 PM | #6 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
in "src/calibre/library/comments.py" see the function "comments_to_html"
|
12-02-2015, 04:05 PM | #7 |
Enthusiast
Posts: 31
Karma: 12920
Join Date: Nov 2014
Device: Voyage 5.8.9.2
|
Thanks guys.
|
01-08-2016, 12:39 PM | #8 |
Grand Sorcerer
Posts: 11,764
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Just for completeness: it is possible to use bulk search/replace to clean HTML out of comments.
Step 1: create a custom template function. In my case I named it myFunc2. The actual text of the function is Code:
def evaluate(self, formatter, kwargs, mi, locals, t): from calibre.utils.html2text import html2text return html2text(t) Code:
<p class="description"><font color="#ff0000">This comment set to red text.</font></p> I checked metadata.opf and indeed the HTML is gone. |
01-08-2016, 12:52 PM | #9 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Oh, cool. Leveraging S&R to evade the comments editor post-processing.
Why didn't I think of that? |
01-08-2016, 04:17 PM | #10 |
Well trained by Cats
Posts: 29,892
Karma: 55267620
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
01-08-2016, 04:23 PM | #11 |
Grand Sorcerer
Posts: 6,259
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
I've made a small plugin with the same goal (among other things )
|
01-09-2016, 08:20 PM | #12 |
Ex-Helpdesk Junkie
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Care to share it?
|
01-11-2016, 12:29 AM | #13 |
Grand Sorcerer
Posts: 6,259
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Not at all. This is my plugin and the function (it's a menu option too) is "_do replace_text). Keep in mind that:
So it probably will be a mess |
01-11-2016, 04:29 PM | #14 |
Enthusiast
Posts: 31
Karma: 12920
Join Date: Nov 2014
Device: Voyage 5.8.9.2
|
Thanks for your suggestion chaley. I tried your suggestion, but couldn't get it to work with the standard comments section. However, I've managed to do it using regex. Tested and it works fine, also tested with an absolutely tag trashed comment and it works too.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Remove all formatting in comments by regular expression | aurigod | Library Management | 2 | 02-05-2015 12:38 PM |
Changing paragraph formatting in Comments field | Berzelius | Calibre | 16 | 10-26-2014 06:40 PM |
How do I paste description (comments) without the html formatting? | webipsum | Calibre | 5 | 07-15-2014 07:38 PM |
COMMENTS batch formatting | ippopom | Library Management | 7 | 02-26-2013 01:23 PM |
[Old Thread] Comments section *formatting* | mezme | Calibre | 5 | 08-26-2011 06:22 PM |