Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 07-26-2023, 09:41 AM   #1
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Snippets

Hi,

I have a snippet for SVG covers:
Code:
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="${1:pt-BR}" xml:lang="${2:pt-BR}">
    <head>
        <title>${3:Capa}</title>
        <style type="text/css" title="override_css">
            @page {padding: 0pt; margin:0pt}
            body { text-align: center; padding:0pt; margin: 0pt; }
        </style>
    </head>
    <body>
        <div>
            <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                width="100%" height="100%" viewBox="0 0 ${4:903} ${5:1354}"
                preserveAspectRatio="xMidYMid meet">
                <image width="${6:903}" height="${7:1354}" xlink:href="${8*:../Images/cover.jpg}"/>
            </svg>
        </div>
    </body>
</html>$9
I use it to transform simple <img> tags into a SVG cover.

To start, I select the image path (e.g.: '../Images/cover.jpg') and press Ctrl+J. The snippet get this path and creates the SVG cover. All good, except for the image height and width, that I have to edit manually.

My question: is it possible to get these attributes as parameters for the snippet? The manual doesn't mention it, but maybe it might be possible.

P.S.: I know I can use the "Add cover" option. But it is very specific for covers, and the lang attribute is always "en". I also use this for other full page images as well.

Last edited by thiago.eec; 07-26-2023 at 09:46 AM.
thiago.eec is offline   Reply With Quote
Old 07-26-2023, 10:24 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,033
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Not sure what you mean by parameters for snippets? Where would you enter the parameters? I suspect you mean you want to fill out the width and height only once. In that case use mirroring, see https://manual.calibre-ebook.com/snippets.html
kovidgoyal is online now   Reply With Quote
Old 07-26-2023, 10:36 AM   #3
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by kovidgoyal View Post
Not sure what you mean by parameters for snippets? Where would you enter the parameters? I suspect you mean you want to fill out the width and height only once. In that case use mirroring, see https://manual.calibre-ebook.com/snippets.html
No, I would like to use a placeholder for the width and another one for height. So, when the image path is selected, the editor would read these attributes and fill in automatically, much like it already does when using the "Add cover" option.

P.S.: Thanks for the tip. I didn't know about mirroring.
thiago.eec is offline   Reply With Quote
Old 07-26-2023, 10:42 AM   #4
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,000
Karma: 57259778
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
I wondered why the Insert Image Tool did not have an AS SVG, tic option with all the expanded options (not just for covers)

Gotta ask: Why not just have Calibre (Main) embed the cover (and metadata)?
theducks is online now   Reply With Quote
Old 07-26-2023, 10:57 AM   #5
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by theducks View Post
I wondered why the Insert Image Tool did not have an AS SVG, tic option with all the expanded options (not just for covers)
Just mark the two options on the footer. It inserts the image in an SVG wrapper. But thats for an image INSIDE the content, not like a cover (a single image in the html file)

Quote:
Originally Posted by theducks View Post
Gotta ask: Why not just have Calibre (Main) embed the cover (and metadata)?
Like I said, calibre uses lang="en", while my books are in "pt-BR". Also, the <title> attribute would be in english. And as for metadata, I rather do it myself, for best control. Also, I have to many custom columns that would be incorporated unnecessarily.
thiago.eec is offline   Reply With Quote
Old 07-26-2023, 11:42 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,033
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by thiago.eec View Post
No, I would like to use a placeholder for the width and another one for height. So, when the image path is selected, the editor would read these attributes and fill in automatically, much like it already does when using the "Add cover" option.

P.S.: Thanks for the tip. I didn't know about mirroring.
No, there is no such facility. snippets know nothing abou thte content you are inserting they are basically just simple text templates.
kovidgoyal is online now   Reply With Quote
Old 07-26-2023, 01:46 PM   #7
thiago.eec
Guru
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 946
Karma: 1183425
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite
Quote:
Originally Posted by kovidgoyal View Post
No, there is no such facility. snippets know nothing abou thte content you are inserting they are basically just simple text templates.
Ok, then. Thanks!
thiago.eec is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
recover snippets only rjwse@aol.com Calibre 2 10-10-2020 07:34 AM
Random crashes using snippets Phssthpok Editor 14 09-23-2017 10:58 PM
Color code and snippets. apoiata Sigil 14 02-22-2017 09:44 PM
Snippets !!! Icon for the toolbar?? phossler Editor 12 01-12-2015 05:05 AM
Emailing snippets from Kindle... gfmucci Amazon Kindle 0 05-17-2010 08:56 AM


All times are GMT -4. The time now is 10:27 AM.


MobileRead.com is a privately owned, operated and funded community.