Home Download Buy Blog Forum Support

ExportHtml Plugin (rename from PrintHtml)

ExportHtml Plugin (rename from PrintHtml)

Postby facelessuser on Wed Apr 18, 2012 5:07 am

@agibsonsw started a plugin to print code to an HTML styled with Sublime Text's syntax highlighting. We started collaborating together, and I polished it up and added a number of features. With @agibsonsw permission I am posting the plugin here.

Image

Features
- Print to HTML using any tmTheme for syntax highlighting
- Can handle any language supported by ST2
- Supports bold and italic theme font styles as well
- Configurable output
- Format suitable for copying and pasting in emails
- 2 included tmTheme files for color and grayscale printing (but any can be used)
- Print only selections (multi-select supported)
- Print and show highlights (multi-select supported)
- Toggle gutter on/off in browser view
- Automatically open browser print dialog (optional)
- Enable/disable configurable word wrapping

Please read the readme for more information.

Repository: https://github.com/facelessuser/ExportHtml

I know there is already a print to HTML plugin now on Package Control. I also know that people are a little picky about plugins that provide similar features on Package Control. If you would like to see this plugin on Package Control, please let me know. I think this offers a unique set of features, but I will leave it up the user base to decide.

Edit: Renamed package
Last edited by facelessuser on Thu Apr 19, 2012 4:49 pm, edited 4 times in total.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby facelessuser on Wed Apr 18, 2012 5:11 am

@agibsonsw and I were discussing this and were not sure if people would be interested in this feature or not, please let us know.

Basically it is a feature which allows you to annotate the document before you print it to HTML. Then in the HTML, the selections you annotated will be underlined. When you mouse over the underlined word(s), a tooltip with your annotation will be shown.

Please chime in and let me know if this is a feature you would be interested in. It is already done, I just need to know if there is interest.

I meant HTML not email in the picture below, but I already made the picture :).

Image
Last edited by facelessuser on Thu Apr 19, 2012 4:49 pm, edited 1 time in total.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby bizoo on Wed Apr 18, 2012 6:38 am

Great plugin, thanks to both of you !

Please put it on Package Control, IMHO your concept to generate HTML is way better than using Pygments module (no offense to other plugin author which is good too).

And this is your first issue (facelessuser: the issues management is not enabled in your github repository):
On Windows when opening in the browser, the page is opened 2 times.
It is caused by the desktop module that return None as status:
Code: Select all
def open(url, desktop=None, wait=0, status=False):
...
    elif desktop_in_use == "Windows":
        # NOTE: This returns None in current implementations.
        return os.startfile(url)

BTW, what's the problem with webbrowser.open() that you have to use desktop module ?
bizoo
 
Posts: 883
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: PrintHtml Plugin

Postby facelessuser on Wed Apr 18, 2012 12:40 pm

bizoo wrote:And this is your first issue (facelessuser: the issues management is not enabled in your github repository):

Issues is now enabled.

bizoo wrote:Please put it on Package Control, IMHO your concept to generate HTML is way better than using Pygments module (no offense to other plugin author which is good too).

Will do.

bizoo wrote:On Windows when opening in the browser, the page is opened 2 times.
It is caused by the desktop module that return None as status:
Code: Select all
def open(url, desktop=None, wait=0, status=False):
...
    elif desktop_in_use == "Windows":
        # NOTE: This returns None in current implementations.
        return os.startfile(url)

BTW, what's the problem with webbrowser.open() that you have to use desktop module ?


Others have tried webbrowser as well, and have had issus in dealing with Linux. Webbrowser doesn't handle Gnome, KDE, XFCE, etc. very well. It stands to reason that maybe I should just check the platform and use Desktop only for Linux. I was going for a universal method that just defaulted to webbrowser if a bad status returned (happens in Mac sometimes if the browser is not open). I will address this sometime today. I wasn't noticing the issue on my Windows box at work, but I can clearly see how that case is an issue.

Thanks for the feedback!
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby facelessuser on Wed Apr 18, 2012 12:50 pm

@bizoo, problem should be fixed now (might need to restart after updating due to dependency inclusion). If it is still an issue, create a issue on github and I will look deeper into it.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby SeanWcom on Wed Apr 18, 2012 1:44 pm

Thanks for all the work (both you and @agibsonsw). This is easily one of my favorite plugins now. :)

I'd love to see the annotation feature added. One of my uses for this is that I run my own local wordpress install as kind of a knowledge base/snippet management tool for my work. Being able to drop in snippets like this, with annotations, would be awesome. Then I wouldn't have to rely on syntax highlighting plugins.
Multiple selections... one of my favorite ST2 features. View some noob-friendly screen casts here.
SeanWcom
 
Posts: 101
Joined: Wed Aug 03, 2011 1:31 am
Location: Georgia

Re: PrintHtml Plugin

Postby seth007 on Wed Apr 18, 2012 1:45 pm

This is an excellent approach! Put it on package-control pls! :D
On Windows when opening in the browser, the page is opened 2 times.


this is still happening...
seth007
 
Posts: 8
Joined: Tue Mar 20, 2012 9:54 pm

Re: PrintHtml Plugin

Postby SeanWcom on Wed Apr 18, 2012 1:47 pm

He just fixed it a few minutes ago... grab it again and try it out. It's working for me now. :)
Multiple selections... one of my favorite ST2 features. View some noob-friendly screen casts here.
SeanWcom
 
Posts: 101
Joined: Wed Aug 03, 2011 1:31 am
Location: Georgia

Re: PrintHtml Plugin

Postby facelessuser on Wed Apr 18, 2012 1:48 pm

seth007 wrote:This is an excellent approach! Put it on package-control pls! :D
On Windows when opening in the browser, the page is opened 2 times.


this is still happening...


Yeah, I am an idiot :oops: . I set it to always open two tabs opposed to not open two tabs.

It should be fixed now...really this time :). I just had confirmation form @SeanWcom that it is now working.

Edit: looks like he confirmed here as well.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby facelessuser on Wed Apr 18, 2012 1:53 pm

SeanWcom wrote:Thanks for all the work (both you and @agibsonsw). This is easily one of my favorite plugins now. :)

I'd love to see the annotation feature added. One of my uses for this is that I run my own local wordpress install as kind of a knowledge base/snippet management tool for my work. Being able to drop in snippets like this, with annotations, would be awesome. Then I wouldn't have to rely on syntax highlighting plugins.


Not a problem, probably later today. What is does is allow you to go into a read only state and add annotations before printing. Just print before leaving annotation mode. You can try out the annotation branch now before I merge it in (it still has the two tab bug though). Annotations are forgotten when leaving annotation mode . It is difficult to track the regions when undo can bring them back form the dead and redo can remove them. So it is simply a commenting method before printing.

https://github.com/facelessuser/PrintHt ... nnotations

Let me know what you think, sorry thee is no documentation on it yet, but the commands should be available in the command palette.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 18 guests