Home Download Buy Blog Forum Support

ExportHtml Plugin (rename from PrintHtml)

Re: PrintHtml Plugin

Postby SeanWcom on Thu Apr 19, 2012 12:46 am

Great job with the updates - loving the context menu stuff. :)
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 Thu Apr 19, 2012 2:15 am

SeanWcom wrote:Great job with the updates - loving the context menu stuff. :)


Glad you like it. I have to say, the context menu makes it easier to use.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby planet on Thu Apr 19, 2012 12:23 pm

Hi,
great Plugin! Unfortunately there seems to be a problem with PHP files (for me) - JSON or Plain Text is working. I have installed the plugin and didn't change any settings. When I want to print a PHP file (from the menu), the console says:

Code: Select all
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 356, in run_
  File ".\PrintToHTML.py", line 44, in run
  File ".\PrintToHTML.py", line 170, in convert_to_html
  File ".\PrintToHTML.py", line 124, in get_lexer
  File ".\pygments\lexers\__init__.py", line 74, in get_lexer_by_name
  File ".\pygments\lexer.py", line 470, in __call__
  File ".\pygments\lexers\web.py", line 870, in __init__
ImportError: No module named _phpbuiltins


Is it a bug or do I have do configure something for PHP files?

Setup: ST2 2194 Nightly, WIN7.

Best regards, Thorsten.
planet
 
Posts: 25
Joined: Fri Feb 17, 2012 12:30 pm

Re: PrintHtml Plugin

Postby agibsonsw on Thu Apr 19, 2012 12:28 pm

Your error message refers to an alternative plugin PrintToHtml rather than PrintHtml. You may want to disable or un-install it so you can test this one without conflict.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: PrintHtml Plugin

Postby facelessuser on Thu Apr 19, 2012 1:14 pm

planet wrote:Hi,
great Plugin! Unfortunately there seems to be a problem with PHP files (for me) - JSON or Plain Text is working. I have installed the plugin and didn't change any settings. When I want to print a PHP file (from the menu), the console says:

Code: Select all
Traceback (most recent call last):
  File ".\sublime_plugin.py", line 356, in run_
  File ".\PrintToHTML.py", line 44, in run
  File ".\PrintToHTML.py", line 170, in convert_to_html
  File ".\PrintToHTML.py", line 124, in get_lexer
  File ".\pygments\lexers\__init__.py", line 74, in get_lexer_by_name
  File ".\pygments\lexer.py", line 470, in __call__
  File ".\pygments\lexers\web.py", line 870, in __init__
ImportError: No module named _phpbuiltins


The bug is not with my plugin "PrintHtml" but with another called "PrintToHtml"; I don't use pygments to convert files.

This brings up an interesting point though. I think I need a more unique name. These two Plugin names seem too similar. I should really address this before moving this to Package Control.

Any suggestions?
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby agibsonsw on Thu Apr 19, 2012 1:55 pm

What about OutputHtml (or HtmlOutput)? or CreateHtml. Or

AndyAndFaceLessUsersFantasticToolForGeneratingHtmlOutput :)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: PrintHtml Plugin

Postby sublimator on Thu Apr 19, 2012 2:20 pm

HtmlExport ?
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: PrintHtml Plugin

Postby facelessuser on Thu Apr 19, 2012 2:21 pm

An attempt to catch BBCode references in code and escape them (by underlining the key word)
NUMBERED_BBCODE_LINE = '[color=%(color)s]%(line)s [/color]%(code)s\n'

BBCODE_LINE = '%(code)s\n'

BBCODE_CODE = '[color=%(color)s]%(content)s[/color]'

BBCODE_ESCAPE = '[/color][color=%(color_open)s]%(content)s[/color][color=%(color_close)s]'

BBCODE_BOLD = '[b]%(content)s[/b]'

BBCODE_ITALIC = '[i]%(content)s[/i]'

POST_START = '[pre=%(bg_color)s]'

POST_END = '[/pre]\n'

BBCODE_MATCH = r"""(\[/?)((?:code|pre|table|tr|td|th|b|i|u|sup|color|url|img|list|trac|center|quote|size|li|ul|ol|youtube|gvideo)(?:=[^\]]+)?)(\])"""


Seems to work :)
[pre=#000000][color=#F8F8F2]NUMBERED_BBCODE_LINE [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][color=[/color][color=#AE81FF]%(color)s[/color][color=#E6DB74]][/color][color=#AE81FF]%(line)s[/color][color=#E6DB74] [/[/color][color=#E6DB74]color[/color][color=#E6DB74]][/color][color=#AE81FF]%(code)s[/color][color=#AE81FF]\n[/color][color=#E6DB74]'[/color]

[color=#F8F8F2]BBCODE_LINE [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#AE81FF]%(code)s[/color][color=#AE81FF]\n[/color][color=#E6DB74]'[/color]

[color=#F8F8F2]BBCODE_CODE [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][color=[/color][color=#AE81FF]%(color)s[/color][color=#E6DB74]][/color][color=#AE81FF]%(content)s[/color][color=#E6DB74][/[/color][color=#E6DB74]color[/color][color=#E6DB74]][/color][color=#E6DB74]'[/color]

[color=#F8F8F2]BBCODE_ESCAPE [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][/[/color][color=#E6DB74]color[/color][color=#E6DB74]][color=[/color][color=#AE81FF]%(color_open)s[/color][color=#E6DB74]][/color][color=#AE81FF]%(content)s[/color][color=#E6DB74][/[/color][color=#E6DB74]color[/color][color=#E6DB74]][color=[/color][color=#AE81FF]%(color_close)s[/color][color=#E6DB74]][/color][color=#E6DB74]'[/color]

[color=#F8F8F2]BBCODE_BOLD [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][[/color][color=#E6DB74]b[/color][color=#E6DB74]][/color][color=#AE81FF]%(content)s[/color][color=#E6DB74][/[/color][color=#E6DB74]b[/color][color=#E6DB74]][/color][color=#E6DB74]'[/color]

[color=#F8F8F2]BBCODE_ITALIC [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][[/color][color=#E6DB74]i[/color][color=#E6DB74]][/color][color=#AE81FF]%(content)s[/color][color=#E6DB74][/[/color][color=#E6DB74]i[/color][color=#E6DB74]][/color][color=#E6DB74]'[/color]

[color=#F8F8F2]POST_START [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][pre=[/color][color=#AE81FF]%(bg_color)s[/color][color=#E6DB74]][/color][color=#E6DB74]'[/color]

[color=#F8F8F2]POST_END [/color][color=#F92672]=[/color][color=#E6DB74] '[/color][color=#E6DB74][/[/color][color=#E6DB74]pre[/color][color=#E6DB74]][/color][color=#AE81FF]\n[/color][color=#E6DB74]'[/color]

[color=#F8F8F2]BBCODE_MATCH [/color][color=#F92672]=[/color][i][color=#66D9EF] r[/color][/i][color=#E6DB74]"""[/color][color=#E6DB74]([/color][color=#AE81FF]\[[/color][color=#E6DB74]/[/color][color=#F92672]?[/color][color=#E6DB74])([/color][color=#E6DB74]([/color][color=#E6DB74]?:[/color][color=#E6DB74]code[/color][color=#F92672]|[/color][color=#E6DB74]pre[/color][color=#F92672]|[/color][color=#E6DB74]table[/color][color=#F92672]|[/color][color=#E6DB74]tr[/color][color=#F92672]|[/color][color=#E6DB74]td[/color][color=#F92672]|[/color][color=#E6DB74]th[/color][color=#F92672]|[/color][color=#E6DB74]b[/color][color=#F92672]|[/color][color=#E6DB74]i[/color][color=#F92672]|[/color][color=#E6DB74]u[/color][color=#F92672]|[/color][color=#E6DB74]sup[/color][color=#F92672]|[/color][color=#E6DB74]color[/color][color=#F92672]|[/color][color=#E6DB74]url[/color][color=#F92672]|[/color][color=#E6DB74]img[/color][color=#F92672]|[/color][color=#E6DB74]list[/color][color=#F92672]|[/color][color=#E6DB74]trac[/color][color=#F92672]|[/color][color=#E6DB74]center[/color][color=#F92672]|[/color][color=#E6DB74]quote[/color][color=#F92672]|[/color][color=#E6DB74]size[/color][color=#F92672]|[/color][color=#E6DB74]li[/color][color=#F92672]|[/color][color=#E6DB74]ul[/color][color=#F92672]|[/color][color=#E6DB74]ol[/color][color=#F92672]|[/color][color=#E6DB74]youtube[/color][color=#F92672]|[/color][color=#E6DB74]gvideo[/color][color=#E6DB74])([/color][color=#E6DB74]?:[/color][color=#E6DB74]=[/color][color=#AE81FF][[/color][color=#F92672]^[/color][color=#AE81FF]\][/color][color=#AE81FF]][/color][color=#F92672]+[/color][color=#E6DB74])[/color][color=#F92672]?[/color][color=#E6DB74])([/color][color=#AE81FF]\][/color][color=#E6DB74])[/color][color=#E6DB74]"""[/color]
[/pre]



Edit:
Even better escaping. No underlines needed, and more reliable.
Last edited by facelessuser on Thu Apr 19, 2012 5:04 pm, edited 4 times in total.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby facelessuser on Thu Apr 19, 2012 2:23 pm

castles_made_of_sand wrote:HtmlExport ?


Nice one. I like it. It is actually more true than PrintHtml. I will make the changes later today (which will probably break current installations, but it has to be done). I will also add the BBCode escape as well.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: PrintHtml Plugin

Postby planet on Thu Apr 19, 2012 3:16 pm

Thanks guys!

I was indeed using PrintToHTML...
planet
 
Posts: 25
Joined: Fri Feb 17, 2012 12:30 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 8 guests