GNOME Bugzilla – Bug 323588
Export highlihgted code
Last modified: 2009-03-24 02:07:20 UTC
It would be nice to be able to save highlighted code from the gtksourceview buffer to html. To What would it be useful ? * to publish code on a blog or regular website that doesn't have highlither * to add code sample to an Open Office presentation * I don't see more but the previous two would be damn useful ! ;-)
I agree it would be cool to have such plugin. It should be not too difficult to find already existing code for this. I remember one of the fist version of gtksourceview had this feature. Look at the gtk_source_buffer_convert_to_html in http://cvs.gnome.org/viewcvs/gtksourceview/gtksourceview/gtksourcebuffer.c?rev=1.19&view=markup I think we could export to XML and then convert to HTML using XSLT.
Created attachment 57185 [details] HTML export plugin for GEdit I've written a plugin that does this. It maybe need some testing, and I know the strings may need some help.. Unpack in "plugins" dir in the gedit source tree and add "htmlexport" to plugins/Makefile.am and "plugins/htmlexport/Makefile" to configure.ac
Created attachment 57224 [details] New version of plugin. The plugin is now standalone, no need to build gedit from source. Fixed a HTML special character escaping bug. Code cleanup.
Created attachment 57229 [details] New version of plugin. * More html special characters escaping and escaping of non-ascii characters. * File replace confirmation dialog.
(In reply to comment #4) > Created an attachment (id=57229) [edit] > New version of plugin. Great ! I'll test it tomorrow or Sunday if I hopefully find time. Just a few comment looking rapidly at the code (I am proficient in C, so take it with a grain of salt ;) ) : * maybe the html could use an embeded style sheet, it might simplify the code as well (dunno). * define a doctype I'll try to have a look and come with something more constructive ;) That said, I think it's a plugin that would logically (at least to me) fit in the list of gedit shipped plugins. Another solution would be not shipping any plugin at all and have them released in a separate tarball, that would increase visibility and awareness of plugins existence, maybe.
* About the embedded stylesheet: I tried that, but this way was much easier to implement, and I wanted a fast solution first. Maybe I'll give it another shot. * Found a bug yesterday, but I don't have time to fix it until later today.
We are moving all the request for plugins that we don't plan to add to gedit itself on live.gnome.org/Gedit. Closing as WONTFIX.
since in this case there is a working plugin, Markuss can you make sure to open a page on the wiki? It would really be appreciated
*** Bug 345427 has been marked as a duplicate of this bug. ***
This plugin really needs to be in File->Export as HTML Actually come to think of it, a lot of gedit plugins should be in gedit as standard. Anyways, Thanks Markus for the plugin.