markopress 0.0.2 → 0.0.4
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/dist/build/index.d.ts +0 -1
- package/dist/build/index.js +1 -1627
- package/dist/build/types.d.ts +0 -1
- package/dist/build/types.js +1 -5
- package/dist/build/vite-markdown-plugin.d.ts +0 -1
- package/dist/build/vite-markdown-plugin.js +1 -147
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +1 -74
- package/dist/config/app-root.d.ts +0 -1
- package/dist/config/app-root.js +1 -24
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.js +1 -6
- package/dist/config/loader.d.ts +0 -1
- package/dist/config/loader.js +1 -188
- package/dist/config/types.d.ts +0 -1
- package/dist/config/types.js +1 -5
- package/dist/config/validation.d.ts +0 -1
- package/dist/config/validation.js +1 -139
- package/dist/content/index.d.ts +0 -1
- package/dist/content/index.js +1 -6
- package/dist/content/registry.d.ts +0 -1
- package/dist/content/registry.js +1 -45
- package/dist/content/types.d.ts +0 -1
- package/dist/content/types.js +1 -5
- package/dist/dev/index.d.ts +0 -1
- package/dist/dev/index.js +1 -93
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -17
- package/dist/markdown/base-path-plugin.d.ts +16 -0
- package/dist/markdown/base-path-plugin.js +1 -0
- package/dist/markdown/code.d.ts +0 -1
- package/dist/markdown/code.js +1 -305
- package/dist/markdown/containers.d.ts +0 -1
- package/dist/markdown/containers.js +1 -143
- package/dist/markdown/includes.d.ts +0 -1
- package/dist/markdown/includes.js +1 -9
- package/dist/markdown/index.d.ts +0 -1
- package/dist/markdown/index.js +1 -8
- package/dist/markdown/loader.d.ts +0 -1
- package/dist/markdown/loader.js +1 -325
- package/dist/markdown/md-link-plugin.d.ts +14 -0
- package/dist/markdown/md-link-plugin.js +1 -0
- package/dist/markdown/preserve-tags.d.ts +0 -1
- package/dist/markdown/preserve-tags.js +1 -233
- package/dist/markdown/renderer.d.ts +0 -1
- package/dist/markdown/renderer.js +1 -146
- package/dist/markdown/tag-validator.d.ts +0 -1
- package/dist/markdown/tag-validator.js +1 -118
- package/dist/markdown/types.d.ts +2 -1
- package/dist/markdown/types.js +1 -5
- package/dist/plugin/compat.d.ts +0 -1
- package/dist/plugin/compat.js +1 -78
- package/dist/plugin/context.d.ts +0 -1
- package/dist/plugin/context.js +1 -103
- package/dist/plugin/index.d.ts +0 -1
- package/dist/plugin/index.js +1 -6
- package/dist/plugin/manager.d.ts +0 -1
- package/dist/plugin/manager.js +1 -385
- package/dist/plugin/types.d.ts +1 -1
- package/dist/plugin/types.js +1 -5
- package/dist/plugins/blog-index/index.d.ts +0 -1
- package/dist/plugins/blog-index/index.js +1 -158
- package/dist/plugins/sidenav/index.d.ts +0 -1
- package/dist/plugins/sidenav/index.js +1 -86
- package/dist/plugins/toc/index.d.ts +0 -1
- package/dist/plugins/toc/index.js +1 -79
- package/dist/preview/index.d.ts +0 -1
- package/dist/preview/index.js +1 -25
- package/dist/theme/default/design-systems/default.d.ts +0 -1
- package/dist/theme/default/design-systems/default.js +1 -289
- package/dist/theme/default/design-systems/docusaurus.d.ts +0 -1
- package/dist/theme/default/design-systems/docusaurus.js +1 -299
- package/dist/theme/default/design-systems/index.d.ts +0 -1
- package/dist/theme/default/design-systems/index.js +1 -54
- package/dist/theme/default/design-systems/rspress.d.ts +0 -1
- package/dist/theme/default/design-systems/rspress.js +1 -299
- package/dist/theme/default/design-systems/types.d.ts +0 -1
- package/dist/theme/default/design-systems/types.js +1 -6
- package/dist/theme/default/design-systems/vitepress.d.ts +0 -1
- package/dist/theme/default/design-systems/vitepress.js +1 -299
- package/dist/theme/default/index.d.ts +0 -1
- package/dist/theme/default/index.js +1 -44
- package/dist/theme/default/theme.d.ts +0 -1
- package/dist/theme/default/theme.js +1 -58
- package/dist/theme/index.d.ts +0 -1
- package/dist/theme/index.js +1 -6
- package/dist/theme/loader.d.ts +0 -1
- package/dist/theme/loader.js +1 -125
- package/dist/theme/types.d.ts +1 -1
- package/dist/theme/types.js +1 -5
- package/dist/vite/index.d.ts +0 -1
- package/dist/vite/index.js +1 -6
- package/dist/vite/markdownPlugin.d.ts +0 -1
- package/dist/vite/markdownPlugin.js +1 -111
- package/dist/vite/plugin.d.ts +0 -1
- package/dist/vite/plugin.js +1 -94
- package/package.json +3 -2
- package/src/theme/default/layouts/blog.marko +1 -1
- package/src/theme/default/layouts/default.marko +5 -5
- package/src/theme/default/layouts/docs.marko +6 -6
- package/src/theme/default/layouts/page.marko +1 -1
- package/templates/catch-all-handler.js.template +2 -17
- package/dist/build/index.d.ts.map +0 -1
- package/dist/build/index.js.map +0 -1
- package/dist/build/manifest-generator.d.ts +0 -34
- package/dist/build/manifest-generator.d.ts.map +0 -1
- package/dist/build/manifest-generator.js +0 -86
- package/dist/build/manifest-generator.js.map +0 -1
- package/dist/build/security.test.d.ts +0 -6
- package/dist/build/security.test.d.ts.map +0 -1
- package/dist/build/security.test.js +0 -88
- package/dist/build/security.test.js.map +0 -1
- package/dist/build/types.d.ts.map +0 -1
- package/dist/build/types.js.map +0 -1
- package/dist/build/vite-config.test.d.ts +0 -2
- package/dist/build/vite-config.test.d.ts.map +0 -1
- package/dist/build/vite-config.test.js +0 -53
- package/dist/build/vite-config.test.js.map +0 -1
- package/dist/build/vite-markdown-plugin.d.ts.map +0 -1
- package/dist/build/vite-markdown-plugin.js.map +0 -1
- package/dist/build/vite-markdown-plugin.test.d.ts +0 -2
- package/dist/build/vite-markdown-plugin.test.d.ts.map +0 -1
- package/dist/build/vite-markdown-plugin.test.js +0 -41
- package/dist/build/vite-markdown-plugin.test.js.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/config/app-root.d.ts.map +0 -1
- package/dist/config/app-root.js.map +0 -1
- package/dist/config/app-root.test.d.ts +0 -2
- package/dist/config/app-root.test.d.ts.map +0 -1
- package/dist/config/app-root.test.js +0 -71
- package/dist/config/app-root.test.js.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/loader.d.ts.map +0 -1
- package/dist/config/loader.js.map +0 -1
- package/dist/config/loader.test.d.ts +0 -2
- package/dist/config/loader.test.d.ts.map +0 -1
- package/dist/config/loader.test.js +0 -24
- package/dist/config/loader.test.js.map +0 -1
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js.map +0 -1
- package/dist/config/validation.d.ts.map +0 -1
- package/dist/config/validation.js.map +0 -1
- package/dist/content/index.d.ts.map +0 -1
- package/dist/content/index.js.map +0 -1
- package/dist/content/registry.d.ts.map +0 -1
- package/dist/content/registry.js.map +0 -1
- package/dist/content/scanner.d.ts +0 -9
- package/dist/content/scanner.d.ts.map +0 -1
- package/dist/content/scanner.js +0 -115
- package/dist/content/scanner.js.map +0 -1
- package/dist/content/types.d.ts.map +0 -1
- package/dist/content/types.js.map +0 -1
- package/dist/dev/index.d.ts.map +0 -1
- package/dist/dev/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown/code.d.ts.map +0 -1
- package/dist/markdown/code.js.map +0 -1
- package/dist/markdown/containers.d.ts.map +0 -1
- package/dist/markdown/containers.js.map +0 -1
- package/dist/markdown/includes.d.ts.map +0 -1
- package/dist/markdown/includes.js.map +0 -1
- package/dist/markdown/index.d.ts.map +0 -1
- package/dist/markdown/index.js.map +0 -1
- package/dist/markdown/loader.d.ts.map +0 -1
- package/dist/markdown/loader.js.map +0 -1
- package/dist/markdown/preserve-tags.d.ts.map +0 -1
- package/dist/markdown/preserve-tags.js.map +0 -1
- package/dist/markdown/renderer.d.ts.map +0 -1
- package/dist/markdown/renderer.js.map +0 -1
- package/dist/markdown/tag-validator.d.ts.map +0 -1
- package/dist/markdown/tag-validator.js.map +0 -1
- package/dist/markdown/types.d.ts.map +0 -1
- package/dist/markdown/types.js.map +0 -1
- package/dist/plugin/compat.d.ts.map +0 -1
- package/dist/plugin/compat.js.map +0 -1
- package/dist/plugin/context.d.ts.map +0 -1
- package/dist/plugin/context.js.map +0 -1
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js.map +0 -1
- package/dist/plugin/manager.d.ts.map +0 -1
- package/dist/plugin/manager.js.map +0 -1
- package/dist/plugin/types.d.ts.map +0 -1
- package/dist/plugin/types.js.map +0 -1
- package/dist/plugins/blog-index/index.d.ts.map +0 -1
- package/dist/plugins/blog-index/index.js.map +0 -1
- package/dist/plugins/sidenav/index.d.ts.map +0 -1
- package/dist/plugins/sidenav/index.js.map +0 -1
- package/dist/plugins/toc/index.d.ts.map +0 -1
- package/dist/plugins/toc/index.js.map +0 -1
- package/dist/preview/index.d.ts.map +0 -1
- package/dist/preview/index.js.map +0 -1
- package/dist/theme/default/build/generate-all.d.ts +0 -9
- package/dist/theme/default/build/generate-all.d.ts.map +0 -1
- package/dist/theme/default/build/generate-all.js +0 -85
- package/dist/theme/default/build/generate-all.js.map +0 -1
- package/dist/theme/default/build/generate-css.d.ts +0 -19
- package/dist/theme/default/build/generate-css.d.ts.map +0 -1
- package/dist/theme/default/build/generate-css.js +0 -199
- package/dist/theme/default/build/generate-css.js.map +0 -1
- package/dist/theme/default/build/index.d.ts +0 -5
- package/dist/theme/default/build/index.d.ts.map +0 -1
- package/dist/theme/default/build/index.js +0 -5
- package/dist/theme/default/build/index.js.map +0 -1
- package/dist/theme/default/design-systems/default.d.ts.map +0 -1
- package/dist/theme/default/design-systems/default.js.map +0 -1
- package/dist/theme/default/design-systems/docusaurus.d.ts.map +0 -1
- package/dist/theme/default/design-systems/docusaurus.js.map +0 -1
- package/dist/theme/default/design-systems/index.d.ts.map +0 -1
- package/dist/theme/default/design-systems/index.js.map +0 -1
- package/dist/theme/default/design-systems/rspress.d.ts.map +0 -1
- package/dist/theme/default/design-systems/rspress.js.map +0 -1
- package/dist/theme/default/design-systems/types.d.ts.map +0 -1
- package/dist/theme/default/design-systems/types.js.map +0 -1
- package/dist/theme/default/design-systems/vitepress.d.ts.map +0 -1
- package/dist/theme/default/design-systems/vitepress.js.map +0 -1
- package/dist/theme/default/index.d.ts.map +0 -1
- package/dist/theme/default/index.js.map +0 -1
- package/dist/theme/default/theme.d.ts.map +0 -1
- package/dist/theme/default/theme.js.map +0 -1
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/index.js.map +0 -1
- package/dist/theme/loader.d.ts.map +0 -1
- package/dist/theme/loader.js.map +0 -1
- package/dist/theme/types.d.ts.map +0 -1
- package/dist/theme/types.js.map +0 -1
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/markdownPlugin.d.ts.map +0 -1
- package/dist/vite/markdownPlugin.js.map +0 -1
- package/dist/vite/plugin.d.ts.map +0 -1
- package/dist/vite/plugin.js.map +0 -1
- package/src/theme/default/build/generate-all.ts +0 -99
- package/src/theme/default/build/generate-css.ts +0 -234
- package/src/theme/default/build/index.ts +0 -5
- package/src/theme/default/components/doc-footer.marko +0 -180
- package/src/theme/default/components/footer.marko +0 -32
- package/src/theme/default/components/header.marko +0 -49
- package/src/theme/default/components/nav-bar.marko +0 -191
- package/src/theme/default/components/page-header.marko +0 -20
- package/src/theme/default/components/reading-progress.marko +0 -36
- package/src/theme/default/components/search.marko +0 -239
- package/src/theme/default/components/sidebar.marko +0 -211
- package/src/theme/default/components/site-footer.marko +0 -211
- package/src/theme/default/components/skip-link.marko +0 -49
- package/src/theme/default/components/theme/theme-aside-bottom.marko +0 -1
- package/src/theme/default/components/theme/theme-aside-top.marko +0 -1
- package/src/theme/default/components/theme/theme-body-bottom.marko +0 -1
- package/src/theme/default/components/theme/theme-body-top.marko +0 -1
- package/src/theme/default/components/theme/theme-doc-bottom.marko +0 -1
- package/src/theme/default/components/theme/theme-doc-footer-after.marko +0 -1
- package/src/theme/default/components/theme/theme-doc-footer-before.marko +0 -1
- package/src/theme/default/components/theme/theme-doc-top.marko +0 -1
- package/src/theme/default/components/theme/theme-head-bottom.marko +0 -1
- package/src/theme/default/components/theme/theme-head-top.marko +0 -1
- package/src/theme/default/components/theme/theme-home-features-after.marko +0 -1
- package/src/theme/default/components/theme/theme-home-hero-after.marko +0 -1
- package/src/theme/default/components/theme/theme-home-hero-before.marko +0 -1
- package/src/theme/default/components/theme/theme-navbar-center.marko +0 -5
- package/src/theme/default/components/theme/theme-navbar-end.marko +0 -30
- package/src/theme/default/components/theme/theme-navbar-start.marko +0 -1
- package/src/theme/default/components/theme/theme-page-bottom.marko +0 -1
- package/src/theme/default/components/theme/theme-page-top.marko +0 -1
- package/src/theme/default/components/theme/theme-sidebar-bottom.marko +0 -1
- package/src/theme/default/components/theme/theme-sidebar-top.marko +0 -1
- package/src/theme/default/components/theme/theme-toc-item.marko +0 -1
- package/src/theme/default/components/theme-toggle.marko +0 -122
- package/src/theme/default/components/toc.marko +0 -140
- package/src/theme/default/design-systems/default.ts +0 -331
- package/src/theme/default/design-systems/docusaurus.ts +0 -341
- package/src/theme/default/design-systems/index.ts +0 -67
- package/src/theme/default/design-systems/rspress.ts +0 -341
- package/src/theme/default/design-systems/types.ts +0 -296
- package/src/theme/default/design-systems/vitepress.ts +0 -341
- package/src/theme/default/index.ts +0 -107
- package/src/theme/default/theme.ts +0 -83
- package/templates/example-tags/README.md +0 -212
- package/templates/example-tags/alert-box.marko +0 -98
- package/templates/example-tags/button-primary.marko +0 -28
- package/templates/example-tags/button-secondary.marko +0 -28
- package/templates/example-tags/button.marko +0 -6
- package/templates/example-tags/card-body.marko +0 -8
- package/templates/example-tags/card-footer.marko +0 -7
- package/templates/example-tags/card-header.marko +0 -7
- package/templates/example-tags/card.marko +0 -20
- package/templates/example-tags/icon.marko +0 -149
package/dist/content/index.d.ts
CHANGED
package/dist/content/index.js
CHANGED
package/dist/content/registry.js
CHANGED
|
@@ -1,45 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Module Registry Stub
|
|
3
|
-
*
|
|
4
|
-
* Kept for backward compatibility. Content modules have been removed
|
|
5
|
-
* in favor of request-time rendering.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Module registry stub - no-op since content is rendered at request time
|
|
9
|
-
*/
|
|
10
|
-
export class ModuleRegistry {
|
|
11
|
-
register(_module) {
|
|
12
|
-
// No-op: modules no longer used
|
|
13
|
-
}
|
|
14
|
-
get(_id) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
getAll() {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
getByType(_type) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
enhance(_id, _key, _data) {
|
|
24
|
-
// No-op
|
|
25
|
-
}
|
|
26
|
-
has(_id) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
getIds() {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
clear() {
|
|
33
|
-
// No-op
|
|
34
|
-
}
|
|
35
|
-
get size() {
|
|
36
|
-
return 0;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create a new module registry instance
|
|
41
|
-
*/
|
|
42
|
-
export function createModuleRegistry() {
|
|
43
|
-
return new ModuleRegistry();
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=registry.js.map
|
|
1
|
+
export class ModuleRegistry{register(e){}get(e){}getAll(){return[]}getByType(e){return[]}enhance(e,r,t){}has(e){return!1}getIds(){return[]}clear(){}get size(){return 0}}export function createModuleRegistry(){return new ModuleRegistry}
|
package/dist/content/types.d.ts
CHANGED
package/dist/content/types.js
CHANGED
package/dist/dev/index.d.ts
CHANGED
package/dist/dev/index.js
CHANGED
|
@@ -1,93 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* MarkoPress Dev Server
|
|
3
|
-
* Development server with automatic route generation
|
|
4
|
-
*/
|
|
5
|
-
import { promises as fs } from 'node:fs';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { spawn } from 'node:child_process';
|
|
8
|
-
import { loadConfig } from '../config/index.js';
|
|
9
|
-
import { PluginManager } from '../plugin/manager.js';
|
|
10
|
-
import { generateRoutes, copyThemeCSS, generateCatchAllRoutes } from '../build/index.js';
|
|
11
|
-
/**
|
|
12
|
-
* Start development server
|
|
13
|
-
*/
|
|
14
|
-
export async function startDevServer(options = {}) {
|
|
15
|
-
console.log('🚀 Starting MarkoPress dev server...\n');
|
|
16
|
-
// Use resolved root or fall back to process.cwd()
|
|
17
|
-
const root = options.root || process.cwd();
|
|
18
|
-
// Load configuration
|
|
19
|
-
const config = await loadConfig(root, { mode: 'development', command: 'dev' });
|
|
20
|
-
console.log(`✓ Config loaded from ${config.root}`);
|
|
21
|
-
// Initialize plugin manager
|
|
22
|
-
let pluginManager;
|
|
23
|
-
if (config.plugins && config.plugins.length > 0) {
|
|
24
|
-
pluginManager = new PluginManager(config);
|
|
25
|
-
await pluginManager.loadPlugins(config.plugins);
|
|
26
|
-
// Execute loadContent hooks to let plugins load external content
|
|
27
|
-
await pluginManager.execLoadContentHooks();
|
|
28
|
-
}
|
|
29
|
-
// Empty manifest for dynamic rendering
|
|
30
|
-
const manifest = {};
|
|
31
|
-
const modules = [];
|
|
32
|
-
console.log('📝 Generating routes from content...');
|
|
33
|
-
const routesDir = path.join(config.root, 'src', 'routes');
|
|
34
|
-
const routeMode = options.useCatchAllRoutes ?? config.build.useCatchAllRoutes;
|
|
35
|
-
// Ensure routes directory exists
|
|
36
|
-
await fs.mkdir(routesDir, { recursive: true });
|
|
37
|
-
// Initialize empty route manifest
|
|
38
|
-
let routeManifest = {};
|
|
39
|
-
// Execute extendRoutes hooks
|
|
40
|
-
if (pluginManager) {
|
|
41
|
-
routeManifest = await pluginManager.execExtendRoutesHooks(routeManifest);
|
|
42
|
-
}
|
|
43
|
-
if (routeMode) {
|
|
44
|
-
await generateCatchAllRoutes(manifest, routesDir, config, modules, false, false);
|
|
45
|
-
console.log(' Using catch-all dynamic routes');
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
await generateRoutes(manifest, routesDir, config, modules, false);
|
|
49
|
-
console.log(' Using static routes');
|
|
50
|
-
}
|
|
51
|
-
console.log(' Routes generated\n');
|
|
52
|
-
// Execute allContentLoaded hooks
|
|
53
|
-
if (pluginManager) {
|
|
54
|
-
await pluginManager.execAllContentLoadedHooks(routeManifest);
|
|
55
|
-
}
|
|
56
|
-
// Copy theme CSS
|
|
57
|
-
console.log('🎨 Copying theme CSS...');
|
|
58
|
-
await copyThemeCSS(config.root, config, false);
|
|
59
|
-
console.log(' Theme CSS copied\n');
|
|
60
|
-
// Theme components are auto-discovered from the markopress package
|
|
61
|
-
// via marko metadata (marko.json + package exports)
|
|
62
|
-
// Start @marko/run dev server
|
|
63
|
-
console.log('🔨 Starting @marko/run dev server...\n');
|
|
64
|
-
const port = options.port || 3000;
|
|
65
|
-
const args = ['dev'];
|
|
66
|
-
if (port) {
|
|
67
|
-
args.push('--port', String(port));
|
|
68
|
-
}
|
|
69
|
-
const devProcess = spawn('npx', ['marko-run', ...args], {
|
|
70
|
-
stdio: 'inherit',
|
|
71
|
-
cwd: config.root,
|
|
72
|
-
});
|
|
73
|
-
devProcess.on('error', (error) => {
|
|
74
|
-
console.error('Failed to start dev server:', error);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
});
|
|
77
|
-
devProcess.on('exit', (code) => {
|
|
78
|
-
if (code !== 0) {
|
|
79
|
-
console.error(`Dev server exited with code ${code}`);
|
|
80
|
-
process.exit(code || 1);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
// Handle process termination
|
|
84
|
-
process.on('SIGINT', () => {
|
|
85
|
-
devProcess.kill('SIGINT');
|
|
86
|
-
process.exit(0);
|
|
87
|
-
});
|
|
88
|
-
process.on('SIGTERM', () => {
|
|
89
|
-
devProcess.kill('SIGTERM');
|
|
90
|
-
process.exit(0);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{promises as o}from"node:fs";import e from"node:path";import{spawn as r}from"node:child_process";import{loadConfig as t}from"../config/index.js";import{PluginManager as s}from"../plugin/manager.js";import{generateRoutes as n,copyThemeCSS as i,generateCatchAllRoutes as c}from"../build/index.js";export async function startDevServer(a={}){console.log("🚀 Starting MarkoPress dev server...\n");const l=a.root||process.cwd(),d=await t(l,{mode:"development",command:"dev"});let m;console.log("✓ Config loaded from "+d.root),d.plugins&&d.plugins.length>0&&(m=new s(d),await m.loadPlugins(d.plugins),await m.execLoadContentHooks());const p=e.join(d.root,"src",".generated","markdown");await o.rm(p,{recursive:!0,force:!0});const g={},u=[];console.log("📝 Generating routes from content...");const v=e.join(d.root,"src","routes"),w=a.useCatchAllRoutes??d.build.useCatchAllRoutes;await o.mkdir(v,{recursive:!0});let x={};m&&(x=await m.execExtendRoutesHooks(x)),w?(await c(g,v,d,u,!1,!1),console.log(" Using catch-all dynamic routes")):(await n(g,v,d,u,!1),console.log(" Using static routes")),console.log(" Routes generated\n"),m&&await m.execAllContentLoadedHooks(x),console.log("🎨 Copying theme CSS..."),await i(d.root,d,!1),console.log(" Theme CSS copied\n"),console.log("🔨 Starting @marko/run dev server...\n");const f=a.port||3e3,h=["dev"];f&&h.push("--port",f+"");const S=r("npx",["marko-run",...h],{stdio:"inherit",cwd:d.root});S.on("error",o=>{console.error("Failed to start dev server:",o),process.exit(1)}),S.on("exit",o=>{0!==o&&(console.error("Dev server exited with code "+o),process.exit(o||1))}),process.on("SIGINT",()=>{S.kill("SIGINT"),process.exit(0)}),process.on("SIGTERM",()=>{S.kill("SIGTERM"),process.exit(0)})}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* MarkoPress - A general-purpose static site generator using Marko.js v6
|
|
3
|
-
*/
|
|
4
|
-
// Core exports
|
|
5
|
-
export * from './config/index.js';
|
|
6
|
-
export * from './markdown/index.js';
|
|
7
|
-
export { PluginManager } from './plugin/index.js';
|
|
8
|
-
export * from './content/index.js';
|
|
9
|
-
export * from './vite/index.js';
|
|
10
|
-
// Theme exports with renaming to avoid conflicts
|
|
11
|
-
export { loadTheme, loadThemeWithOverrides, getLayoutPath, getSlotPath, } from './theme/index.js';
|
|
12
|
-
export { build, generateRoutes, generateCatchAllRoutes } from './build/index.js';
|
|
13
|
-
export * from './preview/index.js';
|
|
14
|
-
export * from './dev/index.js';
|
|
15
|
-
// Note: CLI is NOT exported from main entry to avoid executing program.parse()
|
|
16
|
-
// Import CLI directly from './cli/index.js' if needed
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./config/index.js";export*from"./markdown/index.js";export{PluginManager}from"./plugin/index.js";export*from"./content/index.js";export*from"./vite/index.js";export{loadTheme,loadThemeWithOverrides,getLayoutPath,getSlotPath}from"./theme/index.js";export{build,generateRoutes,generateCatchAllRoutes}from"./build/index.js";export*from"./preview/index.js";export*from"./dev/index.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type MarkdownIt from 'markdown-it';
|
|
2
|
+
/**
|
|
3
|
+
* markdown-it plugin that prefixes absolute internal links with a base path.
|
|
4
|
+
*
|
|
5
|
+
* Rewrites:
|
|
6
|
+
* /features → /markopress/features
|
|
7
|
+
* /blog/my-post → /markopress/blog/my-post
|
|
8
|
+
*
|
|
9
|
+
* Does NOT rewrite:
|
|
10
|
+
* https://... (external)
|
|
11
|
+
* //cdn.com/... (protocol-relative)
|
|
12
|
+
* #section (anchor)
|
|
13
|
+
* mailto:... (non-http)
|
|
14
|
+
* paths already starting with base
|
|
15
|
+
*/
|
|
16
|
+
export declare function basePathPlugin(md: MarkdownIt, base: string): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function basePathPlugin(t,n){const s=n.replace(/\/$/,"");if(!s||"/"===s)return;const o=t.renderer.rules.link_open||((e,r,t,n,s)=>s.renderToken(e,r,t));t.renderer.rules.link_open=(r,t,n,c,l)=>{const i=r[t].attrIndex("href");if(i>=0){const n=r[t].attrs[i][1];r[t].attrs[i][1]=e(n,s)}return o(r,t,n,c,l)};const c=t.renderer.rules.image||((e,r,t,n,s)=>s.renderToken(e,r,t));t.renderer.rules.image=(r,t,n,o,l)=>{const i=r[t].attrIndex("src");if(i>=0){const n=r[t].attrs[i][1];r[t].attrs[i][1]=e(n,s)}return c(r,t,n,o,l)};const l=t.renderer.rules.html_block||((e,r)=>e[r].content);t.renderer.rules.html_block=(e,t,n,o,c)=>(e[t].content=r(e[t].content,s),l(e,t,n,o,c));const i=t.renderer.rules.html_inline||((e,r)=>e[r].content);t.renderer.rules.html_inline=(e,t,n,o,c)=>(e[t].content=r(e[t].content,s),i(e,t,n,o,c))}function e(e,r){return e.startsWith("/")?e.startsWith("//")||e.startsWith(r+"/")||e===r?e:r+e:e}function r(r,t){return r.replace(/((?:href|src)\s*=\s*)(["'])(\/(?!\/)[^"']*)\2/gi,(r,n,s,o)=>n+s+e(o,t)+s)}
|
package/dist/markdown/code.d.ts
CHANGED
|
@@ -76,4 +76,3 @@ export declare function processCodeLines(code: string): ProcessedLine[];
|
|
|
76
76
|
* Supports dual themes (light + dark) in a single pass for dark mode support
|
|
77
77
|
*/
|
|
78
78
|
export declare function createEnhancedHighlighter(highlighter: Highlighter, options?: CodeBlockOptions): (code: string, lang: string, info: string) => string;
|
|
79
|
-
//# sourceMappingURL=code.d.ts.map
|
package/dist/markdown/code.js
CHANGED
|
@@ -1,305 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Code block enhancements for Shiki
|
|
3
|
-
* Implements VitePress-style code features:
|
|
4
|
-
* - Line highlighting: {4}, {5-8}, {4,7,9}
|
|
5
|
-
* - Line numbers
|
|
6
|
-
* - Code titles
|
|
7
|
-
* - Diff syntax (// [!code --], // [!code ++])
|
|
8
|
-
* - Code focus (// [!code focus])
|
|
9
|
-
* - Error/warning annotations (// [!code error], // [!code warning])
|
|
10
|
-
*
|
|
11
|
-
* Uses codeToHast() for better performance - generates HAST (tree) instead of HTML string,
|
|
12
|
-
* then converts to HTML at the end with hastToHtml().
|
|
13
|
-
*/
|
|
14
|
-
import { hastToHtml } from 'shiki';
|
|
15
|
-
/**
|
|
16
|
-
* Parse code block meta string
|
|
17
|
-
* Examples:
|
|
18
|
-
* - ```js{4}
|
|
19
|
-
* - ```js{1,4-6}
|
|
20
|
-
* - ```js:line-numbers
|
|
21
|
-
* - ```js:line-numbers=false
|
|
22
|
-
* - ```js title="my-file.js"
|
|
23
|
-
* - ```js{4} title="Example" :line-numbers
|
|
24
|
-
*/
|
|
25
|
-
export function parseCodeMeta(info, globalLineNumbers = true) {
|
|
26
|
-
const meta = {
|
|
27
|
-
highlightLines: new Set(),
|
|
28
|
-
lineNumbers: globalLineNumbers,
|
|
29
|
-
};
|
|
30
|
-
// Extract language
|
|
31
|
-
const langMatch = info.match(/^([a-z0-9-]+)/);
|
|
32
|
-
if (langMatch) {
|
|
33
|
-
meta.lang = langMatch[1];
|
|
34
|
-
}
|
|
35
|
-
// Extract line highlights {1,4-6,8}
|
|
36
|
-
const highlightMatch = info.match(/\{([0-9,-]+)\}/);
|
|
37
|
-
if (highlightMatch) {
|
|
38
|
-
const ranges = highlightMatch[1].split(',');
|
|
39
|
-
for (const range of ranges) {
|
|
40
|
-
if (range.includes('-')) {
|
|
41
|
-
const [start, end] = range.split('-').map(Number);
|
|
42
|
-
for (let i = start; i <= end; i++) {
|
|
43
|
-
meta.highlightLines.add(i);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
meta.highlightLines.add(Number(range));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// Extract title
|
|
52
|
-
const titleMatch = info.match(/title="([^"]+)"|title='([^']+)'/);
|
|
53
|
-
if (titleMatch) {
|
|
54
|
-
meta.title = titleMatch[1] || titleMatch[2];
|
|
55
|
-
}
|
|
56
|
-
// Extract line-numbers flag
|
|
57
|
-
if (info.includes(':line-numbers') || info.includes(':ln')) {
|
|
58
|
-
meta.lineNumbers = true;
|
|
59
|
-
}
|
|
60
|
-
else if (info.includes(':no-line-numbers') || info.includes(':line-numbers=false')) {
|
|
61
|
-
meta.lineNumbers = false;
|
|
62
|
-
}
|
|
63
|
-
return meta;
|
|
64
|
-
}
|
|
65
|
-
export function processCodeLines(code) {
|
|
66
|
-
const lines = code.split('\n');
|
|
67
|
-
const processed = [];
|
|
68
|
-
for (const line of lines) {
|
|
69
|
-
const result = {
|
|
70
|
-
content: line,
|
|
71
|
-
classes: [],
|
|
72
|
-
};
|
|
73
|
-
// Check for diff markers
|
|
74
|
-
if (line.includes('// [!code --]') || line.includes('// [!code -]')) {
|
|
75
|
-
result.isDiff = true;
|
|
76
|
-
result.diffType = 'remove';
|
|
77
|
-
result.classes.push('diff', 'remove');
|
|
78
|
-
result.content = line.replace(/\/\/ \[!code --?\]/, '').trim();
|
|
79
|
-
}
|
|
80
|
-
else if (line.includes('// [!code ++]') || line.includes('// [!code +]')) {
|
|
81
|
-
result.isDiff = true;
|
|
82
|
-
result.diffType = 'add';
|
|
83
|
-
result.classes.push('diff', 'add');
|
|
84
|
-
result.content = line.replace(/\/\/ \[!code \+\+?\]/, '').trim();
|
|
85
|
-
}
|
|
86
|
-
// Check for focus marker
|
|
87
|
-
if (line.includes('// [!code focus]')) {
|
|
88
|
-
result.isFocus = true;
|
|
89
|
-
result.classes.push('focus');
|
|
90
|
-
result.content = result.content.replace(/\/\/ \[!code focus\]/, '').trim();
|
|
91
|
-
}
|
|
92
|
-
// Check for error marker
|
|
93
|
-
if (line.includes('// [!code error]')) {
|
|
94
|
-
result.isError = true;
|
|
95
|
-
result.classes.push('error');
|
|
96
|
-
result.content = result.content.replace(/\/\/ \[!code error\]/, '').trim();
|
|
97
|
-
}
|
|
98
|
-
// Check for warning marker
|
|
99
|
-
if (line.includes('// [!code warning]')) {
|
|
100
|
-
result.isWarning = true;
|
|
101
|
-
result.classes.push('warning');
|
|
102
|
-
result.content = result.content.replace(/\/\/ \[!code warning\]/, '').trim();
|
|
103
|
-
}
|
|
104
|
-
processed.push(result);
|
|
105
|
-
}
|
|
106
|
-
return processed;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Enhanced code highlighter with line features
|
|
110
|
-
* Uses codeToHast() for better performance - generates HAST (tree) instead of HTML string
|
|
111
|
-
* Supports dual themes (light + dark) in a single pass for dark mode support
|
|
112
|
-
*/
|
|
113
|
-
export function createEnhancedHighlighter(highlighter, options = {}) {
|
|
114
|
-
return (code, lang, info) => {
|
|
115
|
-
const meta = parseCodeMeta(info, options.lineNumbers ?? true);
|
|
116
|
-
// Resolve language alias
|
|
117
|
-
const resolvedLang = options.languageAlias?.[lang] || lang;
|
|
118
|
-
// Process lines for special markers
|
|
119
|
-
const processedLines = processCodeLines(code);
|
|
120
|
-
const cleanCode = processedLines.map((l) => l.content).join('\n');
|
|
121
|
-
// Generate HAST with Shiki using dual themes (light + dark) in one pass
|
|
122
|
-
// This generates CSS variables that switch via parent class (.shiki-dark)
|
|
123
|
-
let hast;
|
|
124
|
-
try {
|
|
125
|
-
hast = highlighter.codeToHast(cleanCode, {
|
|
126
|
-
lang: resolvedLang,
|
|
127
|
-
themes: {
|
|
128
|
-
light: 'github-light',
|
|
129
|
-
dark: 'github-dark',
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
catch (e) {
|
|
134
|
-
// Fallback for unsupported languages - log warning and return plain code
|
|
135
|
-
if (e.message?.includes('language')) {
|
|
136
|
-
console.warn(`[Shiki] Language "${resolvedLang}" not supported, falling back to plain text. ` +
|
|
137
|
-
`Run build with debug=true to see available languages.`);
|
|
138
|
-
}
|
|
139
|
-
return `<pre class="shiki"><code>${escapeHtml(code)}</code></pre>`;
|
|
140
|
-
}
|
|
141
|
-
// Enhance HAST with line features
|
|
142
|
-
enhanceHastWithLineFeatures(hast, meta, processedLines);
|
|
143
|
-
// Convert HAST to HTML
|
|
144
|
-
let html = hastToHtml(hast);
|
|
145
|
-
// Wrap with title if provided
|
|
146
|
-
if (meta.title) {
|
|
147
|
-
html = `<div class="code-block">
|
|
148
|
-
<div class="code-title">${escapeHtml(meta.title)}</div>
|
|
149
|
-
${html}
|
|
150
|
-
</div>`;
|
|
151
|
-
}
|
|
152
|
-
return html;
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Enhance HAST with line numbers, highlights, and other features
|
|
157
|
-
* Works directly on the tree structure for better performance than string manipulation
|
|
158
|
-
*/
|
|
159
|
-
function enhanceHastWithLineFeatures(hast, meta, processedLines) {
|
|
160
|
-
// Find the <pre> element
|
|
161
|
-
const preElement = findElement(hast, 'pre');
|
|
162
|
-
if (!preElement)
|
|
163
|
-
return;
|
|
164
|
-
// Update pre classes
|
|
165
|
-
const existingClasses = preElement.properties?.className || [];
|
|
166
|
-
const preClasses = [
|
|
167
|
-
...(Array.isArray(existingClasses) ? existingClasses : [existingClasses]).filter(Boolean),
|
|
168
|
-
meta.lineNumbers ? 'line-numbers' : '',
|
|
169
|
-
meta.highlightLines?.size ? 'has-highlights' : '',
|
|
170
|
-
].filter(Boolean);
|
|
171
|
-
preElement.properties = { ...preElement.properties, className: preClasses };
|
|
172
|
-
// Find the <code> element
|
|
173
|
-
const codeElement = findElement(preElement, 'code');
|
|
174
|
-
if (!codeElement)
|
|
175
|
-
return;
|
|
176
|
-
// Split code children into lines and enhance each line
|
|
177
|
-
const lines = splitChildrenIntoLines(codeElement.children || []);
|
|
178
|
-
const enhancedChildren = [];
|
|
179
|
-
for (let i = 0; i < lines.length; i++) {
|
|
180
|
-
const lineNodes = lines[i];
|
|
181
|
-
const lineNum = i + 1;
|
|
182
|
-
const processed = processedLines[i] || { classes: [] };
|
|
183
|
-
// Skip empty lines
|
|
184
|
-
if (lineNodes.length === 0 || (lineNodes.length === 1 && isEmptyText(lineNodes[0]))) {
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
// Build classes for this line
|
|
188
|
-
const lineClasses = ['line'];
|
|
189
|
-
if (meta.highlightLines?.has(lineNum)) {
|
|
190
|
-
lineClasses.push('highlighted');
|
|
191
|
-
}
|
|
192
|
-
lineClasses.push(...processed.classes);
|
|
193
|
-
// Find the first element node to attach classes/attributes
|
|
194
|
-
const firstElement = lineNodes.find((node) => node.type === 'element');
|
|
195
|
-
if (firstElement) {
|
|
196
|
-
// Add classes to existing element
|
|
197
|
-
const elemClasses = firstElement.properties?.className || [];
|
|
198
|
-
const combinedClasses = [
|
|
199
|
-
...(Array.isArray(elemClasses) ? elemClasses : [elemClasses]).filter(Boolean),
|
|
200
|
-
...lineClasses,
|
|
201
|
-
];
|
|
202
|
-
firstElement.properties = {
|
|
203
|
-
...firstElement.properties,
|
|
204
|
-
className: combinedClasses,
|
|
205
|
-
};
|
|
206
|
-
// Add data-line attribute if needed
|
|
207
|
-
if (meta.lineNumbers) {
|
|
208
|
-
firstElement.properties['data-line'] = lineNum;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else if (lineNodes[0]) {
|
|
212
|
-
// Wrap text-only line in a span
|
|
213
|
-
const wrapper = {
|
|
214
|
-
type: 'element',
|
|
215
|
-
tagName: 'span',
|
|
216
|
-
properties: {
|
|
217
|
-
className: lineClasses,
|
|
218
|
-
...(meta.lineNumbers && { 'data-line': lineNum }),
|
|
219
|
-
},
|
|
220
|
-
children: lineNodes,
|
|
221
|
-
};
|
|
222
|
-
enhancedChildren.push(wrapper);
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
enhancedChildren.push(...lineNodes);
|
|
226
|
-
}
|
|
227
|
-
// Rebuild code children with newlines between lines
|
|
228
|
-
codeElement.children = [];
|
|
229
|
-
for (let i = 0; i < enhancedChildren.length; i++) {
|
|
230
|
-
codeElement.children.push(enhancedChildren[i]);
|
|
231
|
-
// Add newline between lines (but not after the last one)
|
|
232
|
-
if (i < enhancedChildren.length - 1) {
|
|
233
|
-
codeElement.children.push({ type: 'text', value: '\n' });
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Find an element by tag name in HAST tree
|
|
239
|
-
*/
|
|
240
|
-
function findElement(parent, tagName) {
|
|
241
|
-
if (parent.type !== 'element')
|
|
242
|
-
return null;
|
|
243
|
-
if (parent.tagName === tagName)
|
|
244
|
-
return parent;
|
|
245
|
-
for (const child of parent.children || []) {
|
|
246
|
-
if (child.type === 'element') {
|
|
247
|
-
const found = findElement(child, tagName);
|
|
248
|
-
if (found)
|
|
249
|
-
return found;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Split code element children into lines
|
|
256
|
-
* Text nodes with newlines create line boundaries
|
|
257
|
-
*/
|
|
258
|
-
function splitChildrenIntoLines(children) {
|
|
259
|
-
const lines = [];
|
|
260
|
-
let currentLine = [];
|
|
261
|
-
for (const child of children) {
|
|
262
|
-
if (child.type === 'text') {
|
|
263
|
-
// Split text by newlines
|
|
264
|
-
const parts = child.value.split('\n');
|
|
265
|
-
for (let i = 0; i < parts.length; i++) {
|
|
266
|
-
if (i > 0) {
|
|
267
|
-
// Newline encountered - start a new line
|
|
268
|
-
lines.push(currentLine);
|
|
269
|
-
currentLine = [];
|
|
270
|
-
}
|
|
271
|
-
if (parts[i]) {
|
|
272
|
-
// Only add non-empty text
|
|
273
|
-
currentLine.push({ type: 'text', value: parts[i] });
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
// Element node - add to current line
|
|
279
|
-
currentLine.push(child);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
// Don't forget the last line
|
|
283
|
-
if (currentLine.length > 0) {
|
|
284
|
-
lines.push(currentLine);
|
|
285
|
-
}
|
|
286
|
-
return lines;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Check if a node is an empty text node
|
|
290
|
-
*/
|
|
291
|
-
function isEmptyText(node) {
|
|
292
|
-
return node.type === 'text' && !node.value;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Escape HTML entities
|
|
296
|
-
*/
|
|
297
|
-
function escapeHtml(text) {
|
|
298
|
-
return text
|
|
299
|
-
.replace(/&/g, '&')
|
|
300
|
-
.replace(/</g, '<')
|
|
301
|
-
.replace(/>/g, '>')
|
|
302
|
-
.replace(/"/g, '"')
|
|
303
|
-
.replace(/'/g, ''');
|
|
304
|
-
}
|
|
305
|
-
//# sourceMappingURL=code.js.map
|
|
1
|
+
import{hastToHtml as e}from"shiki";export function parseCodeMeta(e,t=!0){const n={highlightLines:new Set,lineNumbers:t},s=e.match(/^([a-z0-9-]+)/);s&&(n.lang=s[1]);const i=e.match(/\{([0-9,-]+)\}/);if(i){const e=i[1].split(",");for(const t of e)if(t.includes("-")){const[e,s]=t.split("-").map(Number);for(let t=e;t<=s;t++)n.highlightLines.add(t)}else n.highlightLines.add(Number(t))}const r=e.match(/title="([^"]+)"|title='([^']+)'/);return r&&(n.title=r[1]||r[2]),e.includes(":line-numbers")||e.includes(":ln")?n.lineNumbers=!0:(e.includes(":no-line-numbers")||e.includes(":line-numbers=false"))&&(n.lineNumbers=!1),n}export function processCodeLines(e){const t=e.split("\n"),n=[];for(const e of t){const t={content:e,classes:[]};e.includes("// [!code --]")||e.includes("// [!code -]")?(t.isDiff=!0,t.diffType="remove",t.classes.push("diff","remove"),t.content=e.replace(/\/\/ \[!code --?\]/,"").trim()):(e.includes("// [!code ++]")||e.includes("// [!code +]"))&&(t.isDiff=!0,t.diffType="add",t.classes.push("diff","add"),t.content=e.replace(/\/\/ \[!code \+\+?\]/,"").trim()),e.includes("// [!code focus]")&&(t.isFocus=!0,t.classes.push("focus"),t.content=t.content.replace(/\/\/ \[!code focus\]/,"").trim()),e.includes("// [!code error]")&&(t.isError=!0,t.classes.push("error"),t.content=t.content.replace(/\/\/ \[!code error\]/,"").trim()),e.includes("// [!code warning]")&&(t.isWarning=!0,t.classes.push("warning"),t.content=t.content.replace(/\/\/ \[!code warning\]/,"").trim()),n.push(t)}return n}export function createEnhancedHighlighter(i,r={}){return(l,c,o)=>{const a=parseCodeMeta(o,r.lineNumbers??!0),u=r.languageAlias?.[c]||c,p=processCodeLines(l),h=p.map(e=>e.content).join("\n");let d;try{d=i.codeToHast(h,{lang:u,themes:{light:"github-light",dark:"github-dark"}})}catch(e){return e.message?.includes("language")&&console.warn(`[Shiki] Language "${u}" not supported, falling back to plain text. Run build with debug=true to see available languages.`),`<pre class="shiki"><code>${s(l)}</code></pre>`}!function(e,s,i){const r=t(e,"pre");if(!r)return;const l=r.properties?.className||[],c=[...(Array.isArray(l)?l:[l]).filter(Boolean),s.lineNumbers?"line-numbers":"",s.highlightLines?.size?"has-highlights":""].filter(Boolean);r.properties={...r.properties,className:c};const o=t(r,"code");if(!o)return;const a=function(e){const t=[];let n=[];for(const s of e)if("text"===s.type){const e=s.value.split("\n");for(let s=0;s<e.length;s++)s>0&&(t.push(n),n=[]),e[s]&&n.push({type:"text",value:e[s]})}else n.push(s);return n.length>0&&t.push(n),t}(o.children||[]),u=[];for(let e=0;e<a.length;e++){const t=a[e],r=e+1,l=i[e]||{classes:[]};if(0===t.length||1===t.length&&n(t[0]))continue;const c=["line"];s.highlightLines?.has(r)&&c.push("highlighted"),c.push(...l.classes);const o=t.find(e=>"element"===e.type);if(o){const e=o.properties?.className||[],t=[...(Array.isArray(e)?e:[e]).filter(Boolean),...c];o.properties={...o.properties,className:t},s.lineNumbers&&(o.properties["data-line"]=r)}else if(t[0]){const e={type:"element",tagName:"span",properties:{className:c,...s.lineNumbers&&{"data-line":r}},children:t};u.push(e);continue}u.push(...t)}o.children=[];for(let e=0;e<u.length;e++)o.children.push(u[e]),e<u.length-1&&o.children.push({type:"text",value:"\n"})}(d,a,p);let f=e(d);return a.title&&(f=`<div class="code-block">\n <div class="code-title">${s(a.title)}</div>\n ${f}\n</div>`),f}}function t(e,n){if("element"!==e.type)return null;if(e.tagName===n)return e;for(const s of e.children||[])if("element"===s.type){const e=t(s,n);if(e)return e}return null}function n(e){return"text"===e.type&&!e.value}function s(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}
|