md2x 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +128069 -0
- package/dist/md2x.mjs +128296 -0
- package/dist/renderer/puppeteer-render-worker.js +815 -0
- package/dist/renderer/puppeteer-render.html +2829 -0
- package/dist/themes/code-themes/business-contrast.json +31 -0
- package/dist/themes/code-themes/colorful.json +32 -0
- package/dist/themes/code-themes/cool-modern.json +31 -0
- package/dist/themes/code-themes/high-contrast.json +31 -0
- package/dist/themes/code-themes/light-clean.json +31 -0
- package/dist/themes/code-themes/warm-book.json +31 -0
- package/dist/themes/color-schemes/candy.json +34 -0
- package/dist/themes/color-schemes/cool.json +34 -0
- package/dist/themes/color-schemes/coral.json +34 -0
- package/dist/themes/color-schemes/dino.json +34 -0
- package/dist/themes/color-schemes/forest.json +34 -0
- package/dist/themes/color-schemes/garden.json +34 -0
- package/dist/themes/color-schemes/neutral.json +34 -0
- package/dist/themes/color-schemes/ocean.json +34 -0
- package/dist/themes/color-schemes/rainbow.json +43 -0
- package/dist/themes/color-schemes/sakura.json +34 -0
- package/dist/themes/color-schemes/sepia.json +34 -0
- package/dist/themes/color-schemes/space.json +34 -0
- package/dist/themes/color-schemes/starry.json +34 -0
- package/dist/themes/color-schemes/sunset.json +34 -0
- package/dist/themes/color-schemes/warm.json +34 -0
- package/dist/themes/font-config.json +184 -0
- package/dist/themes/layout-schemes/academic.json +40 -0
- package/dist/themes/layout-schemes/book.json +40 -0
- package/dist/themes/layout-schemes/document.json +40 -0
- package/dist/themes/layout-schemes/magazine.json +40 -0
- package/dist/themes/layout-schemes/student.json +40 -0
- package/dist/themes/layout-schemes/technical.json +40 -0
- package/dist/themes/presets/academic.json +24 -0
- package/dist/themes/presets/business.json +22 -0
- package/dist/themes/presets/candy.json +23 -0
- package/dist/themes/presets/century.json +22 -0
- package/dist/themes/presets/coral.json +22 -0
- package/dist/themes/presets/default.json +22 -0
- package/dist/themes/presets/dinosaur.json +23 -0
- package/dist/themes/presets/elegant.json +22 -0
- package/dist/themes/presets/forest.json +22 -0
- package/dist/themes/presets/garamond.json +22 -0
- package/dist/themes/presets/garden.json +23 -0
- package/dist/themes/presets/handwritten.json +23 -0
- package/dist/themes/presets/heiti.json +22 -0
- package/dist/themes/presets/magazine.json +24 -0
- package/dist/themes/presets/manuscript.json +22 -0
- package/dist/themes/presets/minimal.json +22 -0
- package/dist/themes/presets/mixed.json +24 -0
- package/dist/themes/presets/newspaper.json +24 -0
- package/dist/themes/presets/ocean.json +22 -0
- package/dist/themes/presets/palatino.json +22 -0
- package/dist/themes/presets/rainbow.json +23 -0
- package/dist/themes/presets/space.json +23 -0
- package/dist/themes/presets/starry.json +23 -0
- package/dist/themes/presets/sunset.json +22 -0
- package/dist/themes/presets/swiss.json +22 -0
- package/dist/themes/presets/technical.json +22 -0
- package/dist/themes/presets/typewriter.json +23 -0
- package/dist/themes/presets/verdana.json +22 -0
- package/dist/themes/presets/water.json +22 -0
- package/dist/themes/registry.json +270 -0
- package/dist/themes/table-styles/academic.json +30 -0
- package/dist/themes/table-styles/borderless.json +26 -0
- package/dist/themes/table-styles/compact.json +24 -0
- package/dist/themes/table-styles/grid.json +22 -0
- package/dist/themes/table-styles/high-contrast.json +22 -0
- package/dist/themes/table-styles/minimal-gray.json +26 -0
- package/dist/themes/table-styles/modern-tech.json +34 -0
- package/dist/themes/table-styles/professional.json +34 -0
- package/dist/themes/table-styles/zebra.json +22 -0
- package/dist/types/node/src/host/browser-renderer.d.ts +40 -0
- package/dist/types/node/src/host/node-exporter.d.ts +63 -0
- package/dist/types/node/src/host/node-platform.d.ts +30 -0
- package/dist/types/node/src/index.d.ts +8 -0
- package/dist/types/src/core/markdown-block-splitter.d.ts +16 -0
- package/dist/types/src/core/markdown-document.d.ts +286 -0
- package/dist/types/src/core/markdown-processor.d.ts +228 -0
- package/dist/types/src/core/viewer/viewer-controller.d.ts +85 -0
- package/dist/types/src/exporters/docx-blockquote-converter.d.ts +24 -0
- package/dist/types/src/exporters/docx-code-highlighter.d.ts +14 -0
- package/dist/types/src/exporters/docx-download.d.ts +27 -0
- package/dist/types/src/exporters/docx-exporter.d.ts +77 -0
- package/dist/types/src/exporters/docx-image-utils.d.ts +71 -0
- package/dist/types/src/exporters/docx-inline-converter.d.ts +124 -0
- package/dist/types/src/exporters/docx-list-converter.d.ts +50 -0
- package/dist/types/src/exporters/docx-math-converter.d.ts +11 -0
- package/dist/types/src/exporters/docx-table-converter.d.ts +22 -0
- package/dist/types/src/exporters/mml2omml.d.ts +2 -0
- package/dist/types/src/exporters/theme-to-docx.d.ts +144 -0
- package/dist/types/src/plugins/base-plugin.d.ts +67 -0
- package/dist/types/src/plugins/canvas-plugin.d.ts +9 -0
- package/dist/types/src/plugins/dot-plugin.d.ts +9 -0
- package/dist/types/src/plugins/html-plugin.d.ts +28 -0
- package/dist/types/src/plugins/index.d.ts +56 -0
- package/dist/types/src/plugins/infographic-plugin.d.ts +9 -0
- package/dist/types/src/plugins/mermaid-plugin.d.ts +9 -0
- package/dist/types/src/plugins/plugin-content-utils.d.ts +40 -0
- package/dist/types/src/plugins/plugin-html-utils.d.ts +23 -0
- package/dist/types/src/plugins/rehype-image-uri.d.ts +13 -0
- package/dist/types/src/plugins/remark-super-sub.d.ts +17 -0
- package/dist/types/src/plugins/remark-toc-filter.d.ts +10 -0
- package/dist/types/src/plugins/svg-plugin.d.ts +51 -0
- package/dist/types/src/plugins/vega-plugin.d.ts +10 -0
- package/dist/types/src/plugins/vegalite-plugin.d.ts +23 -0
- package/dist/types/src/types/cache.d.ts +85 -0
- package/dist/types/src/types/core.d.ts +99 -0
- package/dist/types/src/types/docx.d.ts +240 -0
- package/dist/types/src/types/index.d.ts +18 -0
- package/dist/types/src/types/messaging.d.ts +142 -0
- package/dist/types/src/types/platform.d.ts +203 -0
- package/dist/types/src/types/plugin.d.ts +101 -0
- package/dist/types/src/types/render.d.ts +57 -0
- package/dist/types/src/types/theme.d.ts +234 -0
- package/dist/types/src/types/toolbar.d.ts +53 -0
- package/dist/types/src/ui/popup/i18n-helpers.d.ts +21 -0
- package/dist/types/src/ui/popup/settings-tab.d.ts +56 -0
- package/dist/types/src/ui/popup/storage-helper.d.ts +12 -0
- package/dist/types/src/utils/fetch-utils.d.ts +12 -0
- package/dist/types/src/utils/hash.d.ts +17 -0
- package/dist/types/src/utils/html-sanitizer.d.ts +26 -0
- package/dist/types/src/utils/localization.d.ts +49 -0
- package/dist/types/src/utils/theme-manager.d.ts +152 -0
- package/dist/types/src/utils/theme-to-css.d.ts +171 -0
- package/package.json +47 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme to CSS Converter
|
|
3
|
+
* Converts theme configuration to CSS styles
|
|
4
|
+
*
|
|
5
|
+
* Theme v2.0 Format:
|
|
6
|
+
* - fontScheme: only font families (no sizes)
|
|
7
|
+
* - layoutScheme: all sizes and spacing (absolute pt values)
|
|
8
|
+
* - colorScheme: colors (text, accent, code background)
|
|
9
|
+
* - tableStyle: table styling
|
|
10
|
+
* - codeTheme: code syntax highlighting
|
|
11
|
+
*/
|
|
12
|
+
import type { ColorScheme } from '../types/index';
|
|
13
|
+
/**
|
|
14
|
+
* Heading style configuration (font-related properties only)
|
|
15
|
+
*/
|
|
16
|
+
interface HeadingConfig {
|
|
17
|
+
fontFamily?: string;
|
|
18
|
+
fontWeight?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Font scheme configuration (font-related properties only)
|
|
22
|
+
* Layout properties (fontSize, lineHeight, spacing) are in LayoutScheme
|
|
23
|
+
* Color properties are in ColorScheme
|
|
24
|
+
*/
|
|
25
|
+
interface FontScheme {
|
|
26
|
+
body: {
|
|
27
|
+
fontFamily: string;
|
|
28
|
+
};
|
|
29
|
+
headings: {
|
|
30
|
+
fontFamily: string;
|
|
31
|
+
fontWeight?: string;
|
|
32
|
+
[key: string]: string | HeadingConfig | undefined;
|
|
33
|
+
};
|
|
34
|
+
code: {
|
|
35
|
+
fontFamily: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Theme configuration (v2.0 format)
|
|
40
|
+
*/
|
|
41
|
+
export interface ThemeConfig {
|
|
42
|
+
fontScheme: FontScheme;
|
|
43
|
+
layoutScheme: string;
|
|
44
|
+
colorScheme: string;
|
|
45
|
+
tableStyle: string;
|
|
46
|
+
codeTheme: string;
|
|
47
|
+
/** Diagram rendering style: 'normal' or 'handDrawn' (default: 'handDrawn') */
|
|
48
|
+
diagramStyle?: 'normal' | 'handDrawn';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Border configuration (layout properties only, color from ColorScheme)
|
|
52
|
+
*/
|
|
53
|
+
interface BorderConfig {
|
|
54
|
+
style: string;
|
|
55
|
+
width: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Table style configuration (layout properties only, colors from ColorScheme)
|
|
59
|
+
*/
|
|
60
|
+
export interface TableStyleConfig {
|
|
61
|
+
border?: {
|
|
62
|
+
all?: BorderConfig;
|
|
63
|
+
headerTop?: BorderConfig;
|
|
64
|
+
headerBottom?: BorderConfig;
|
|
65
|
+
rowBottom?: BorderConfig;
|
|
66
|
+
lastRowBottom?: BorderConfig;
|
|
67
|
+
};
|
|
68
|
+
header: {
|
|
69
|
+
fontWeight?: string;
|
|
70
|
+
fontSize?: string;
|
|
71
|
+
};
|
|
72
|
+
cell: {
|
|
73
|
+
padding: string;
|
|
74
|
+
};
|
|
75
|
+
zebra?: {
|
|
76
|
+
enabled: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Code theme configuration
|
|
81
|
+
*/
|
|
82
|
+
export interface CodeThemeConfig {
|
|
83
|
+
colors: Record<string, string>;
|
|
84
|
+
foreground: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Layout scheme heading configuration
|
|
88
|
+
*/
|
|
89
|
+
interface LayoutHeadingConfig {
|
|
90
|
+
fontSize: string;
|
|
91
|
+
spacingBefore: string;
|
|
92
|
+
spacingAfter: string;
|
|
93
|
+
alignment?: 'left' | 'center' | 'right';
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Layout scheme block configuration
|
|
97
|
+
*/
|
|
98
|
+
interface LayoutBlockConfig {
|
|
99
|
+
spacingBefore?: string;
|
|
100
|
+
spacingAfter?: string;
|
|
101
|
+
paddingVertical?: string;
|
|
102
|
+
paddingHorizontal?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Layout scheme configuration (absolute pt values)
|
|
106
|
+
*/
|
|
107
|
+
export interface LayoutScheme {
|
|
108
|
+
id: string;
|
|
109
|
+
name: string;
|
|
110
|
+
name_en: string;
|
|
111
|
+
description: string;
|
|
112
|
+
description_en?: string;
|
|
113
|
+
body: {
|
|
114
|
+
fontSize: string;
|
|
115
|
+
lineHeight: number;
|
|
116
|
+
};
|
|
117
|
+
headings: {
|
|
118
|
+
h1: LayoutHeadingConfig;
|
|
119
|
+
h2: LayoutHeadingConfig;
|
|
120
|
+
h3: LayoutHeadingConfig;
|
|
121
|
+
h4: LayoutHeadingConfig;
|
|
122
|
+
h5: LayoutHeadingConfig;
|
|
123
|
+
h6: LayoutHeadingConfig;
|
|
124
|
+
};
|
|
125
|
+
code: {
|
|
126
|
+
fontSize: string;
|
|
127
|
+
};
|
|
128
|
+
blocks: {
|
|
129
|
+
paragraph: LayoutBlockConfig;
|
|
130
|
+
list: LayoutBlockConfig;
|
|
131
|
+
listItem: LayoutBlockConfig;
|
|
132
|
+
blockquote: LayoutBlockConfig;
|
|
133
|
+
codeBlock: LayoutBlockConfig;
|
|
134
|
+
table: LayoutBlockConfig;
|
|
135
|
+
horizontalRule: LayoutBlockConfig;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Font configuration for themeManager
|
|
140
|
+
*/
|
|
141
|
+
export interface FontConfig {
|
|
142
|
+
[key: string]: unknown;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Convert theme configuration to CSS
|
|
146
|
+
* @param theme - Theme configuration object
|
|
147
|
+
* @param layoutScheme - Layout scheme configuration
|
|
148
|
+
* @param colorScheme - Color scheme configuration
|
|
149
|
+
* @param tableStyle - Table style configuration
|
|
150
|
+
* @param codeTheme - Code highlighting theme
|
|
151
|
+
* @returns CSS string
|
|
152
|
+
*/
|
|
153
|
+
export declare function themeToCSS(theme: ThemeConfig, layoutScheme: LayoutScheme, colorScheme: ColorScheme, tableStyle: TableStyleConfig, codeTheme: CodeThemeConfig): string;
|
|
154
|
+
/**
|
|
155
|
+
* Apply theme CSS to the page
|
|
156
|
+
* @param css - CSS string to apply
|
|
157
|
+
*/
|
|
158
|
+
export declare function applyThemeCSS(css: string): void;
|
|
159
|
+
/**
|
|
160
|
+
* Load and apply complete theme
|
|
161
|
+
* Platforms only need to call this with themeId - all theme logic is handled internally
|
|
162
|
+
* @param themeId - Theme ID to load
|
|
163
|
+
*/
|
|
164
|
+
export declare function loadAndApplyTheme(themeId: string): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Switch to a different theme with smooth transition
|
|
167
|
+
* @param themeId - Theme ID to switch to
|
|
168
|
+
* @returns Success status
|
|
169
|
+
*/
|
|
170
|
+
export declare function switchTheme(themeId: string): Promise<boolean>;
|
|
171
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "md2x",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Markdown → PDF/DOCX converter (local, no server). Supports Mermaid/Graphviz/Vega/HTML/SVG rendering, math, and code highlighting.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"bin": {
|
|
8
|
+
"md2x": "dist/md2x.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "node build.mjs",
|
|
23
|
+
"dev": "node build.mjs --watch --run",
|
|
24
|
+
"cli": "node dist/md2x.mjs",
|
|
25
|
+
"test": "node test/node.test.mjs",
|
|
26
|
+
"postinstall": "puppeteer browsers install chrome",
|
|
27
|
+
"prepublishOnly": "node build.mjs"
|
|
28
|
+
},
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/xicilion/markdown-viewer-extension.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/xicilion/markdown-viewer-extension",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/xicilion/markdown-viewer-extension/issues"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"puppeteer": "24.35.0"
|
|
46
|
+
}
|
|
47
|
+
}
|