Skip to content

Commit 1a1b355

Browse files
committed
cleanup
1 parent e13e6d5 commit 1a1b355

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

src/ObsidianTheme.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import { ThemeRegistration } from 'shiki';
22
import * as hast_util_to_html_lib_types from 'hast-util-to-html/lib/types';
33
import * as hast_types from 'hast';
44

5-
interface Theme {
6-
theme: ThemeRegistration;
7-
mapping: Map<string, string>;
8-
reverseMapping: Map<string, string>;
9-
}
10-
115
export class ThemeMapper {
126
mapCounter: number;
137
mapping: Map<string, string>;
@@ -17,8 +11,8 @@ export class ThemeMapper {
1711
this.mapping = new Map();
1812
}
1913

20-
getTheme(): Theme {
21-
const theme: ThemeRegistration = {
14+
getTheme(): ThemeRegistration {
15+
return {
2216
displayName: OBSIDIAN_THEME.displayName,
2317
name: OBSIDIAN_THEME.name,
2418
semanticHighlighting: OBSIDIAN_THEME.semanticHighlighting,
@@ -37,14 +31,6 @@ export class ThemeMapper {
3731
return newToken;
3832
}),
3933
};
40-
41-
const reverseMapping = this.getReverseMapping();
42-
43-
return {
44-
theme: theme,
45-
mapping: this.mapping,
46-
reverseMapping: reverseMapping,
47-
};
4834
}
4935

5036
mapColor(color: string): string {
@@ -58,14 +44,6 @@ export class ThemeMapper {
5844
}
5945
}
6046

61-
private getReverseMapping(): Map<string, string> {
62-
const reverseMapping = new Map<string, string>();
63-
this.mapping.forEach((value, key) => {
64-
reverseMapping.set(value, key);
65-
});
66-
return reverseMapping;
67-
}
68-
6947
fixAST(ast: hast_util_to_html_lib_types.Parent): hast_util_to_html_lib_types.Parent {
7048
ast.children = ast.children.map(child => {
7149
if (child.type === 'element') {

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ const languageNameBlacklist = new Set(['c++', 'c#', 'f#']);
1212
export default class ShikiPlugin extends Plugin {
1313
async onload(): Promise<void> {
1414
const themeMapper = new ThemeMapper();
15-
const theme = themeMapper.getTheme();
1615

1716
const ec = new ExpressiveCodeEngine({
18-
themes: [new ExpressiveCodeTheme(theme.theme)],
17+
themes: [new ExpressiveCodeTheme(themeMapper.getTheme())],
1918
plugins: [
2019
pluginShiki({
2120
langs: Object.values(bundledLanguages),
@@ -56,6 +55,7 @@ export default class ShikiPlugin extends Plugin {
5655
const rederResult = await ec.render({
5756
code: source,
5857
language: shikiLanguage,
58+
// TODO: parse from code block
5959
meta: '{1-2}',
6060
});
6161

0 commit comments

Comments
 (0)