Skip to content

Commit 94f5fe4

Browse files
[tex_to_unicode] Interface v2.0
1 parent b13835e commit 94f5fe4

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

tex_to_unicode/__init__.py

+16-23
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# Copyright (c) 2022 Manuel Schneider
44

5-
import os
65
import re
76
import unicodedata
7+
from pathlib import Path
8+
from pylatexenc.latex2text import LatexNodes2Text
89

910
from albert import *
10-
from pylatexenc.latex2text import LatexNodes2Text
1111

12-
md_iid = '1.0'
13-
md_version = "1.1"
12+
md_iid = '2.0'
13+
md_version = "1.2"
1414
md_name = "TeX to Unicode"
1515
md_description = "Convert TeX mathmode commands to unicode characters"
1616
md_license = "GPL-3.0"
@@ -19,25 +19,18 @@
1919
md_maintainers = "@DenverCoder1"
2020

2121

22-
class Plugin(TriggerQueryHandler):
23-
def id(self) -> str:
24-
return md_id
25-
26-
def name(self) -> str:
27-
return md_name
28-
29-
def description(self) -> str:
30-
return md_description
31-
32-
def defaultTrigger(self) -> str:
33-
return "tex "
34-
35-
def synopsis(self) -> str:
36-
return "<tex input>"
22+
class Plugin(PluginInstance, TriggerQueryHandler):
3723

38-
def initialize(self) -> None:
24+
def __init__(self):
25+
TriggerQueryHandler.__init__(self,
26+
id=md_id,
27+
name=md_name,
28+
description=md_description,
29+
synopsis='<tex input>',
30+
defaultTrigger='tex ')
31+
PluginInstance.__init__(self, extensions=[self])
3932
self.COMBINING_LONG_SOLIDUS_OVERLAY = "\u0338"
40-
self.icon = [os.path.dirname(__file__) + "/tex.png"]
33+
self.iconUrls = [f"file:{Path(__file__).parent}/tex.png"]
4134

4235
def _create_item(self, text: str, subtext: str, can_copy: bool) -> Item:
4336
actions = []
@@ -49,11 +42,11 @@ def _create_item(self, text: str, subtext: str, can_copy: bool) -> Item:
4942
lambda t=text: setClipboardText(t),
5043
)
5144
)
52-
return Item(
45+
return StandardItem(
5346
id=md_id,
54-
icon=self.icon,
5547
text=text,
5648
subtext=subtext,
49+
iconUrls=self.iconUrls,
5750
actions=actions,
5851
)
5952

0 commit comments

Comments
 (0)