Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while using "PostgreSQL Console" #12

Open
100cube opened this issue Oct 17, 2019 · 1 comment
Open

Error while using "PostgreSQL Console" #12

100cube opened this issue Oct 17, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@100cube
Copy link

100cube commented Oct 17, 2019

Trying to highlight PostgreSQL Console raises exception

Hi,
First, thanks for your great add-on.
I was trying to highlight some SQL and psql ( the command line interface for PostgreSQL).

Steps to reproduce

  1. Enter the following text in the Add window.
    \dt
  2. Select PostgresSQL console (psql) from the language dropdown, highlight the text entered and try either pressing alt-S or clicking on the highlight button (LIGHTENING).

I ended up getting the following error

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. 
If the issue only occurs when add-ons are enabled, please use the Tools>Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. 
When you've discovered the add-on that is causing the problem, please report the issue on the add-ons section of our support site. 
Debug info:
Anki 2.1.15 (442df9d6) Python 3.7.4 Qt 5.12.5 PyQt 5.13.1
Platform: Linux
Flags: frz=False ao=True sv=1
Add-ons possibly involved: Syntax Highlighting for Code

Caught exception:
  File "/usr/share/anki/aqt/editor.py", line 138, in <lambda>
    activated = lambda s=self: func(s))
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/main.py", line 412, in highlight_code
    highlight(code, my_lexer, my_formatter),
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/__init__.py", line 85, in highlight
    return format(lex(code, lexer), formatter, outfile)
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/__init__.py", line 64, in format
    formatter.format(tokens, realoutfile)
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/formatter.py", line 95, in format
    return self.format_unencoded(tokensource, outfile)
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/formatters/html.py", line 850, in format_unencoded
    for t, piece in source:
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/formatters/html.py", line 690, in _wrap_div
    for tup in inner:
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/formatters/html.py", line 708, in _wrap_pre
    for tup in inner:
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/formatters/html.py", line 727, in _format_lines
    for ttype, value in tokensource:
  File "/home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/lexer.py", line 191, in streamer
    for _, t, v in self.get_tokens_unprocessed(text):
<class 'RuntimeError'>: generator raised StopIteration

NOTE

I have used a few different other lexers, including normal SQL (which doesn't work for the psql commands). It's only this lexer, so far, that is not working for me and the issue seems with that specific lexer.

Thanks.

@100cube 100cube added the bug Something isn't working label Oct 17, 2019
@100cube
Copy link
Author

100cube commented Oct 17, 2019

Hi @glutanimate
I just compared libs/pgments/lexers to upstream and noticed this repo is a bit behind.
You might want to update the lexers when you get the chance.

Temporary workaround for anyone with similar problem

Backup the file /home/<USERNAME>/.local/share/Anki2/addons21/1463041493/libs/pygments/lexers/sql.py and replace it with this file. It seems working fine now for me.

Thanks again for your great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant