Skip to content

Commit cd908e1

Browse files
committed
Include the bracket counter in the tokenizer to make faster
1 parent a680ca5 commit cd908e1

8 files changed

Lines changed: 100307 additions & 80 deletions

File tree

public/themes/oneDarkPro.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
color: #98c379;
5353
}
5454

55+
/* Quote color */
56+
.aurora-quote {
57+
color: #98c379;
58+
}
59+
5560
/* Single quote color */
5661
.aurora-quote.single {
5762
color: #98c379;

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import tokenizer from './tokenizer.js';
2-
import nodeGenerator from './node_generator.js';
3-
import classHighlighter, { inlineHighlighter } from './highlighter.js';
41
import { one_dark_pro } from './constants.js';
2+
import classHighlighter, { inlineHighlighter } from './highlighter.js';
3+
import nodeGenerator from './node_generator.js';
4+
import tokenizer from './tokenizer.js';
55

66
export type AuroraConfig =
77
| {
@@ -18,14 +18,14 @@ const defaultConfig: AuroraConfig = {
1818

1919
export default function aurora(code: string, config = defaultConfig) {
2020
const tokens = tokenizer(code);
21-
const nodes = nodeGenerator(tokens);
21+
// const nodes = nodeGenerator(tokens);
2222
let highlighted = '';
2323
if (config.mode === 'class') {
24-
highlighted = classHighlighter(nodes);
24+
highlighted = classHighlighter(tokens);
2525
} else {
26-
highlighted = inlineHighlighter(nodes, config.styles || one_dark_pro);
26+
highlighted = inlineHighlighter(tokens, config.styles || one_dark_pro);
2727
}
2828
return highlighted;
2929
}
3030

31-
export { tokenizer, nodeGenerator, classHighlighter, inlineHighlighter, one_dark_pro };
31+
export { classHighlighter, inlineHighlighter, nodeGenerator, one_dark_pro, tokenizer };

src/node_generator.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Token } from './tokenizer.js';
33
export type Node = {
44
type: string;
55
value: string;
6-
subtype?: string;
76
};
87

98
export default function nodeGenerator(tokens: Token[]) {
@@ -40,9 +39,9 @@ export default function nodeGenerator(tokens: Token[]) {
4039
square_count--;
4140
square_count >= 0 && (token.type += ' bracket' + (square_count % 3));
4241
break;
43-
case 'quote':
44-
token.type += ' ' + token.subtype;
45-
break;
42+
// case 'quote':
43+
// token.type += ' ' + token.subtype;
44+
// break;
4645
default:
4746
break;
4847
}

0 commit comments

Comments
 (0)