gregorias / anki-code-highlighter

Anki plugin for code syntax highlighting.
GNU Affero General Public License v3.0
54 stars 3 forks source link

HTML Angular support #73

Closed BartoszPiwek closed 6 months ago

BartoszPiwek commented 6 months ago

Please add support for Angular HTML template

image
gregorias commented 6 months ago

Hi Bartek,

Thanks for reporting the need for a new highlighter.

If Highlight.js supports this language (or Pygments), I can add it to the plugin as well. However, neither Highlight.js nor Pygment have it right now, and, realistically, I will not have the bandwidth to change that myself.

Your best option for this is to add a support for Angular HTML in either of those dependencies and let me know.

BartoszPiwek commented 6 months ago

Yes, pygment have Angular as option but unfortunately using it cause 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, repeat 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 23.10.1 (fac9e0ee) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3
Platform: macOS-14.1.2-arm64-arm-64bit
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-12-09 17:18:04
Add-ons possibly involved: ⁨Highlight Code⁩

Caught exception:
Traceback (most recent call last):
  File "aqt.webview", line 628, in handler
  File "/Users/bartekpiwek/Library/Application Support/Anki2/addons21/112228974/ankieditorextra.py", line 217, in transform_field
    highlighted_selection = highlight_html2html(selection) or selection
  File "/Users/bartekpiwek/Library/Application Support/Anki2/addons21/112228974/ankieditorextra.py", line 118, in highlight_selection
    highlighted_selection = highlighter(selection_soup.text)
  File "/Users/bartekpiwek/Library/Application Support/Anki2/addons21/112228974/main.py", line 339, in format
    return pygments_highlighter.highlight(code,
  File "/Users/bartekpiwek/Library/Application Support/Anki2/addons21/112228974/pygments_highlighter.py", line 53, in highlight
    lexer = pygments.lexers.get_lexer_by_name(language)
  File "/Users/bartekpiwek/Library/Application Support/Anki2/addons21/112228974/pygments/lexers/__init__.py", line 131, in get_lexer_by_name
    raise ClassNotFound('no lexer for alias %r found' % _alias)
pygments.util.ClassNotFound: no lexer for alias 'Angular2' found
gregorias commented 6 months ago

Huh, indeed. That's a bug, I'll fix it shortly.