n1k0 / SublimeHighlight

A humble SublimeText package for exporting highlighted code as RTF or HTML

Home Page:https://github.com/n1k0/SublimeHighlight

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error in pygments

owend opened this issue · comments

Fresh install of plugin via package control on MacOS Mountain Lion

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./SublimeHighlight.py", line 97, in run
  File "./SublimeHighlight.py", line 92, in highlight
  File "./SublimeHighlight.py", line 82, in get_lexer
  File "./pygments/lexers/__init__.py", line 121, in get_lexer_for_filename
  File "./pygments/lexer.py", line 470, in __call__
  File "./pygments/lexers/web.py", line 870, in __init__
ImportError: No module named _phpbuiltins

I can see that the _phpbuiltins.py file exists in the pygments/lexers subdirectory but it hasn't been compiled into a .pyc file. Any suggestions for next steps to take?

Damn, so this issue strikes back… I encountered it some times at the times I was bootstrapping the plugin, it's weird… looks like a Sublime Text 2 issue, but I'm not sure

commented

I have a same problem.
Ubuntu 12.10, Sublime Text Dev build 2220.

ImportError: No module named _phpbuiltins
Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./SublimeHighlight.py", line 97, in run
  File "./SublimeHighlight.py", line 92, in highlight
  File "./SublimeHighlight.py", line 82, in get_lexer
  File "./pygments/lexers/__init__.py", line 121, in get_lexer_for_filename
  File "./pygments/lexer.py", line 470, in __call__
  File "./pygments/lexers/web.py", line 870, in __init__
ImportError: No module named _phpbuiltins

Same problem :( Mountain Lion

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./SublimeHighlight.py", line 97, in run
  File "./SublimeHighlight.py", line 92, in highlight
  File "./SublimeHighlight.py", line 82, in get_lexer
  File "./pygments/lexers/__init__.py", line 121, in get_lexer_for_filename
  File "./pygments/lexer.py", line 470, in __call__
  File "./pygments/lexers/web.py", line 870, in __init__
ImportError: No module named _phpbuiltins

Okay, looks like a problem related to PHP syntax highlighting only. I'm investigating.

This is a really, really weird issue with pygments and/or sublime text python env. I've updated Pygments and forced loading of the _phpbuiltins lexer module, and its solved the problem on my box… but that's nearly black voodoo.

So tell me if this fixes your problem as well.

@n1k0 Now is working, but only if I do it for an entire file, if I select some text (an entire function for example) there are no colors copied (I don't know if is how it works)

That's because you have to copy the <?php opening tag, looks like that's how Pygments work :/

Here you go https://bitbucket.org/birkenfeld/pygments-main/issue/137/bug-in-pygments-php-lexer

I can't do much about this, unfortunately :/

Edit: damn, I misread the author's answer, looks like the startinline option may solve your issue.

So as stated in the README:

Lexer options

SublimeHighlight supports Pygments lexer options. To set an option for a given lexer, eg. PHP:

{
    "lexer_options": {
        "PHP": {
            "startinline": true
        }
    }
}