Home Download Buy Blog Forum Support

ST3: ExportHtml

ST3: ExportHtml

Postby facelessuser on Sat Feb 16, 2013 12:09 am

Here is the initial port of ExportHtml to ST3 https://github.com/facelessuser/ExportHtml/tree/ST3

Seems to work fine, but report bugs here if they are found.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 2:40 am

What's the speed like? I'm guessing you are doing an arse load of match_selector calls?

I've ported some plugins that had a lot of `pt in range(n, m)` forms that are drastically slower on ST3 :/
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: ST3: ExportHtml

Postby facelessuser on Sat Feb 16, 2013 3:39 am

I do do a number of score selectors, but not as many as you would think.

I grab the scope name from the selection and then compare all of the theme scopes with score_selector. Once I determine the best matches, I add the scope name with the best theme scope matches for foreground, background, etc. to the dictionary and never have to run score_selector on the same scope again.

I don't notice much of a difference with the ST2 version and the ST3 version for this plugin.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 4:36 am

Ah, yes, of course the ranking would be memoized eh?

Ah, I guess I meant more the view.scope_name() thingy which you still have to do pt by pt eh.

facelessuser wrote:I don't notice much of a difference with the ST2 version and the ST3 version for this plugin.


That's good to hear. I've mainly only ran into annoyances when using pt by pt substr() stuff. I just assumed it'd be similar for other pt by pt.
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: ST3: ExportHtml

Postby facelessuser on Sat Feb 16, 2013 4:51 am

castles_made_of_sand wrote:Ah, I guess I meant more the view.scope_name() thingy which you still have to do pt by pt eh.


Yeah, there is no getting around that. But it seems fine.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 5:10 am

Code: Select all
Traceback (most recent call last):
  File "/home/nick/.config/sublime-text-3/Packages/ExportHtml/ExportBbcode.py", line 38, in execute
    ExportBbcode(view).run(**self.args[value])
  File "/home/nick/.config/sublime-text-3/Packages/ExportHtml/ExportBbcode.py", line 334, in run
    self.setup(**inputs)
  File "/home/nick/.config/sublime-text-3/Packages/ExportHtml/ExportBbcode.py", line 117, in setup
    self.plist_file = self.apply_filters(readPlist(path_packages + colour_scheme.replace('Packages', '')))
  File "X/plistlib.py", line 73, in readPlist
    pathOrFile = open(pathOrFile, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/home/nick/.config/sublime-text-3/Packages/Color Scheme - Default/Blackboard.tmTheme'


Guess there is some issue with the now zipped package assets huh?
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: ST3: ExportHtml

Postby facelessuser on Sat Feb 16, 2013 5:16 am

Hmm. That is a problem. I use a non-default theme, so I didn't notice or think about that. I will have to look into figuring out how to identify zipped assets and then unpack them...argh...
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 5:30 am

What a pita eh ? I think Jon said he's adding a resource api at some point.

You basically need to check the zip path which would be either in sublime.installed_packages() or near the executable_path()

Then it's possible even if the zip is still there, that just one of the package assets has been overridden by a user.

The __file__ path on the python files gets .sublime-package but things like view.settings().get(syntax|color_scheme) etc all leave you guessing.
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: ST3: ExportHtml

Postby facelessuser on Sat Feb 16, 2013 5:48 am

Yeah, stuff like this takes the fun out of writing plugins. I really don't like doing coding gymnastics just to access a theme file.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3: ExportHtml

Postby sublimator on Sat Feb 16, 2013 5:50 am

Just ported my ghetto version. It's about 10 times slower than before FFFFFFFF :/

( Did you ever find a way to allow bbcode tags as part of the bb export ?)

if bulletin_board:
# print css
bbcode = ["{pre=%s}" % dict(css[None]).get('background-color', '#000000')]
A
= bbcode.append
from lxml.html import fromstring
import re

for txt in fromstring(html).xpath('//text()'):
if txt.is_tail or txt.is_text:
parent
= txt.getparent()
if txt.is_tail: parent = parent.getparent()
style
= None

while parent is not None:
style
= parent.get('style')
if style: break
else: parent = parent.getparent()

color
= re.search(r'(?<!background-)color:(#[A-Fa-f0-9]+)', parent.get('style'))
if color:
color
= color.group(1)
else:
color
= dict(css[None]).get('color', '#000000')

A(
"{color=%s}%s{/color}" % (color, txt))

html
= "".join(bbcode + ["{/pre}"])
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

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests