Massive update to html rendering
This commit is contained in:
parent
d550f057c5
commit
10c84d2dce
5 changed files with 25 additions and 33 deletions
10
bun.lock
10
bun.lock
|
@ -4,7 +4,7 @@
|
||||||
"": {
|
"": {
|
||||||
"name": "@proscenium/muse",
|
"name": "@proscenium/muse",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@proscenium/playbill": "0.0.4",
|
"@proscenium/playbill": "link:@proscenium/playbill",
|
||||||
"chalk": "^5.4.1",
|
"chalk": "^5.4.1",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"yaml": "^2.7.0",
|
"yaml": "^2.7.0",
|
||||||
|
@ -39,9 +39,9 @@
|
||||||
|
|
||||||
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@1.9.4", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="],
|
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@1.9.4", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="],
|
||||||
|
|
||||||
"@proscenium/playbill": ["@proscenium/playbill@0.0.4", "https://git.astral.camp/api/packages/proscenium/npm/%40proscenium%2Fplaybill/-/0.0.4/playbill-0.0.4.tgz", { "dependencies": { "lodash-es": "^4.17.21", "marked": "^15.0.7", "zod": "^3.24.2" } }, "sha512-0E+92ECdLMpOOWnZ4xOYiQ2TxDuEfB2MWC1LPrVrVpedr4ebDDbEzC+m7WjInQCH+y90YGArpuMPaGt6iN43ag=="],
|
"@proscenium/playbill": ["@proscenium/playbill@link:@proscenium/playbill", {}],
|
||||||
|
|
||||||
"@types/bun": ["@types/bun@1.2.4", "", { "dependencies": { "bun-types": "1.2.4" } }, "sha512-QtuV5OMR8/rdKJs213iwXDpfVvnskPXY/S0ZiFbsTjQZycuqPbMW8Gf/XhLfwE5njW8sxI2WjISURXPlHypMFA=="],
|
"@types/bun": ["@types/bun@1.2.5", "", { "dependencies": { "bun-types": "1.2.5" } }, "sha512-w2OZTzrZTVtbnJew1pdFmgV99H0/L+Pvw+z1P67HaR18MHOzYnTYOi6qzErhK8HyT+DB782ADVPPE92Xu2/Opg=="],
|
||||||
|
|
||||||
"@types/lodash": ["@types/lodash@4.17.16", "", {}, "sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g=="],
|
"@types/lodash": ["@types/lodash@4.17.16", "", {}, "sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g=="],
|
||||||
|
|
||||||
|
@ -51,14 +51,12 @@
|
||||||
|
|
||||||
"@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],
|
"@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],
|
||||||
|
|
||||||
"bun-types": ["bun-types@1.2.4", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-nDPymR207ZZEoWD4AavvEaa/KZe/qlrbMSchqpQwovPZCKc7pwMoENjEtHgMKaAjJhy+x6vfqSBA1QU3bJgs0Q=="],
|
"bun-types": ["bun-types@1.2.5", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-3oO6LVGGRRKI4kHINx5PIdIgnLRb7l/SprhzqXapmoYkFl5m4j6EvALvbDVuuBFaamB46Ap6HCUxIXNLCGy+tg=="],
|
||||||
|
|
||||||
"chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="],
|
"chalk": ["chalk@5.4.1", "", {}, "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w=="],
|
||||||
|
|
||||||
"lodash-es": ["lodash-es@4.17.21", "", {}, "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="],
|
"lodash-es": ["lodash-es@4.17.21", "", {}, "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw=="],
|
||||||
|
|
||||||
"marked": ["marked@15.0.7", "", { "bin": { "marked": "bin/marked.js" } }, "sha512-dgLIeKGLx5FwziAnsk4ONoGwHwGPJzselimvlVskE9XLN4Orv9u2VA3GWw/lYUqjfA0rUT/6fqKwfZJapP9BEg=="],
|
|
||||||
|
|
||||||
"typescript": ["typescript@5.8.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="],
|
"typescript": ["typescript@5.8.2", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ=="],
|
||||||
|
|
||||||
"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
|
"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@proscenium/playbill": "0.0.4",
|
"@proscenium/playbill": "link:@proscenium/playbill",
|
||||||
"chalk": "^5.4.1",
|
"chalk": "^5.4.1",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"yaml": "^2.7.0",
|
"yaml": "^2.7.0",
|
||||||
|
|
|
@ -121,6 +121,8 @@ async function main(): Promise<number> {
|
||||||
|
|
||||||
for await (const event of watcher) {
|
for await (const event of watcher) {
|
||||||
console.log(`Detected ${event.eventType} on ${event.filename}`);
|
console.log(`Detected ${event.eventType} on ${event.filename}`);
|
||||||
|
|
||||||
|
try {
|
||||||
lastProcessResult = await processBinding(cliArguments);
|
lastProcessResult = await processBinding(cliArguments);
|
||||||
|
|
||||||
if (lastProcessResult === ExitCode.Error) {
|
if (lastProcessResult === ExitCode.Error) {
|
||||||
|
@ -128,6 +130,10 @@ async function main(): Promise<number> {
|
||||||
} else {
|
} else {
|
||||||
console.log("Reprocessed changes");
|
console.log("Reprocessed changes");
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error processing ${event.filename}`);
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ExitCode.Success;
|
return ExitCode.Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import {
|
import {
|
||||||
|
IDSchema,
|
||||||
PlaybillSchema,
|
PlaybillSchema,
|
||||||
type Playbill,
|
type Playbill,
|
||||||
type UnknownResource,
|
type UnknownResource,
|
||||||
|
@ -14,6 +15,12 @@ const HTMLRenderOptionsSchema = z.object({
|
||||||
styles: z.array(z.string()).optional(),
|
styles: z.array(z.string()).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const PageDefinitionSchema = z.object({
|
||||||
|
id: z.string(),
|
||||||
|
title: z.string(),
|
||||||
|
resources: z.array(IDSchema),
|
||||||
|
});
|
||||||
|
|
||||||
const BindingFileSchema = z.object({
|
const BindingFileSchema = z.object({
|
||||||
$binding: z.literal("playbill"),
|
$binding: z.literal("playbill"),
|
||||||
extends: z.string().optional(),
|
extends: z.string().optional(),
|
||||||
|
@ -25,6 +32,8 @@ const BindingFileSchema = z.object({
|
||||||
files: z.array(z.string()).default(["**/*.yaml", "**/*.md"]),
|
files: z.array(z.string()).default(["**/*.yaml", "**/*.md"]),
|
||||||
|
|
||||||
html: HTMLRenderOptionsSchema.optional(),
|
html: HTMLRenderOptionsSchema.optional(),
|
||||||
|
|
||||||
|
pages: PageDefinitionSchema.array().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type BindingFileContent = z.infer<typeof BindingFileSchema>;
|
type BindingFileContent = z.infer<typeof BindingFileSchema>;
|
||||||
|
@ -45,6 +54,7 @@ export interface PlaybillBinding {
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
html?: z.infer<typeof HTMLRenderOptionsSchema>;
|
html?: z.infer<typeof HTMLRenderOptionsSchema>;
|
||||||
|
pages?: z.infer<typeof PageDefinitionSchema>[];
|
||||||
|
|
||||||
playbill: Playbill;
|
playbill: Playbill;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
import rehypeStringify from "rehype-stringify";
|
|
||||||
import remarkGfm from "remark-gfm";
|
|
||||||
import remarkParse from "remark-parse";
|
|
||||||
import remarkRehype from "remark-rehype";
|
|
||||||
import { unified } from "unified";
|
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
|
|
||||||
const FRONTMATTER_REGEX = /^---[\s\S]*?---/gm;
|
const FRONTMATTER_REGEX = /^---[\s\S]*?---/gm;
|
||||||
|
@ -58,20 +53,3 @@ ${YAML.stringify(frontmatterToWrite)}
|
||||||
${markdown.trim()}
|
${markdown.trim()}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a string of markdown, convert it to HTML
|
|
||||||
*
|
|
||||||
* @param markdown The markdown to convert
|
|
||||||
* @returns A promise resolving to the HTML representation of the markdown
|
|
||||||
*/
|
|
||||||
export async function markdownToHtml(markdown: string): Promise<string> {
|
|
||||||
const rendered = await unified()
|
|
||||||
.use(remarkParse)
|
|
||||||
.use(remarkGfm)
|
|
||||||
.use(remarkRehype)
|
|
||||||
.use(rehypeStringify)
|
|
||||||
.process(markdown);
|
|
||||||
|
|
||||||
return String(rendered);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue