11-14-2023, 02:48 AM | #1 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
Template function to strip HTML?
I have a question about templates (I guess with that I am in the correct lace her at "Library Management", right?):
How can I strip HTML tags from a field in a template? I had a look at The calibre template language, but could not find anything for stripping HTML... Background: The comments field might contain a lot of HTML (crap) which I don't want to see when I show it in a library column. |
11-14-2023, 02:50 AM | #2 |
null operator (he/him)
Posts: 20,673
Karma: 26966376
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
Advert | |
|
11-14-2023, 03:03 AM | #3 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
That's certainly one way to go: Getting rid of the formatting altogether. But in the Book pane on the right the formatting might serve a purpose.
So I thought just getting rid of it for the display as a column might be the gentler approach. Are there extensions for the template language? |
11-14-2023, 03:18 AM | #4 |
null operator (he/him)
Posts: 20,673
Karma: 26966376
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
|
11-14-2023, 04:47 AM | #5 |
Grand Sorcerer
Posts: 11,779
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Yes. You can add your own template functions written in python (User-defined Python template functions), and you can write entire templates in python (Python Template Mode). Both of these can use whatever bits of calibre you wish, although I suggest you be very careful if the function/template changes calibre's database.
The documentation @BR is referring to is here. |
Advert | |
|
11-16-2023, 03:08 AM | #6 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
Aha, yes, that's cool. Thanks heaps. A lot to study though: Good for the weekend!
|
11-16-2023, 03:20 AM | #7 |
want to learn what I want
Posts: 1,045
Karma: 6422750
Join Date: Sep 2020
Device: Calibre E-book viewer
|
I've never tried this plugin myself, but I think it can do what you want:
https://www.mobileread.com/forums/sh...d.php?t=333861 |
Tags |
html attributes, template language, templates |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Can Calibre Strip HTML links when exporting to epub? | Dasun | Calibre | 6 | 03-03-2020 02:47 AM |
Using built-in template functions in a custom template function | ilovejedd | Library Management | 4 | 01-28-2018 12:20 PM |
Problem with contains function in save template | MicaOlaAdams | Calibre | 5 | 10-21-2016 10:25 AM |
How to Clean/Strip HTML from epub file? | Jimbo724 | General Discussions | 9 | 12-12-2012 11:22 AM |
Save Template: Strip out spaces | Agama | Devices | 3 | 03-17-2012 03:12 PM |