Skip to content

Commit 8fb23e1

Browse files
committed
maint(pat-syntax-highlight): Switch to class based pattern.
1 parent b8ecca4 commit 8fb23e1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/pat/syntax-highlight/syntax-highlight.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import Base from "../../core/base";
1+
import { BasePattern } from "../../core/basepattern";
22
import Parser from "../../core/parser";
3+
import registry from "../../core/registry";
34

45
export const parser = new Parser("syntax-highlight");
56
parser.addArgument("language", "html");
67
parser.addArgument("theme", "dark", ["dark", "light"]);
78
parser.addArgument("features", null, ["line-highlight", "line-numbers"], true);
89

9-
export default Base.extend({
10-
name: "syntax-highlight",
11-
trigger: ".pat-syntax-highlight",
10+
class Pattern extends BasePattern {
11+
static name = "syntax-highlight";
12+
static trigger = ".pat-syntax-highlight";
13+
parser = parser;
1214

1315
async init() {
14-
this.options = parser.parse(this.el, this.options);
15-
1616
let theme;
1717
if (this.options.theme === "light") {
1818
theme = "";
@@ -58,5 +58,9 @@ export default Base.extend({
5858
_el.classList.add(`language-${language}`);
5959

6060
Prism.highlightElement(_el);
61-
},
62-
});
61+
}
62+
}
63+
64+
registry.register(Pattern);
65+
export default Pattern;
66+
export { Pattern };

0 commit comments

Comments
 (0)