I have written a empty html page (with some javascript logic embedded) so I can copy/paste a svg content file inside its <body> tag. My little logic parse the <svg> tag and add a checkbox to hide or make visible each layer contained in the svg.
I am ok with this, but now I would like to automate this more, and add a special "save as.." option iniside inkscape, that would 'wrap' svg content in the html page/ javascript logic, to avoid copy/paste and output directly my html file with layer options.
I have searched in inkex's documentation, but I do not really find where to start, has anybody any hints on that?
If anybody is interested, here is the extension modified to reach my goal.
If you create a new svg file in inkscape, with several items attached to different layer, and save it as 'Html Layer (*.html)', when you open the html file in a web browser, you should have a check box showing up for each layer contained in the inkscape file. You can hide/show every layer when unchecking/checking. Original visibility is same as when saved in inkscape.
Hello,
I have written a empty html page (with some javascript logic embedded) so I can copy/paste a svg content file inside its <body> tag. My little logic parse the <svg> tag and add a checkbox to hide or make visible each layer contained in the svg.
I am ok with this, but now I would like to automate this more, and add a special "save as.." option iniside inkscape, that would 'wrap' svg content in the html page/ javascript logic, to avoid copy/paste and output directly my html file with layer options.
I have searched in inkex's documentation, but I do not really find where to start, has anybody any hints on that?
Thanks,
Claude
Do you just want to do:
<html>.your html template.............
<svg>............</svg>
</html>
or insert at a very specific point in the html document ?
It's a bit complicated in that the nice formatting that you see when Inkscape saves an svg file is created by the core program.
It is not created by the extension system.
As a workaround. It's possible to have Inkscape save the svg to a temp folder, then load that text into a variable.
Then add a header and footer to the text then save as .html
I've attached an example export extension.
If you unzip into your Inkscape user extension folder it will add "HTML Header and Footer" to the Inskcape save dropdown.
The header and footer is in the .py file as """ quoted text.
Of course you could make this external - or make a dialogue box for pasting etc.
It seems to work the way I need,
I will test and adapt it later,
Thank you very much
Hello,
If anybody is interested, here is the extension modified to reach my goal.
If you create a new svg file in inkscape, with several items attached to different layer, and save it as 'Html Layer (*.html)', when you open the html file in a web browser, you should have a check box showing up for each layer contained in the inkscape file. You can hide/show every layer when unchecking/checking. Original visibility is same as when saved in inkscape.
Again, thank you Inklinea for the great help