///
import { type JSONSchema, NAME, recipe, str, UI } from "commontools";
import TurndownService from "turndown";
const Input = {
type: "object",
properties: {
foo: {
type: "string",
},
},
required: ["foo"],
description: "input",
} as const satisfies JSONSchema;
const Output = {
type: "object",
properties: {
items: {
type: "array",
items: {
type: "string",
},
},
},
} as const satisfies JSONSchema;
function assert(condition: boolean, message: string) {
if (!condition) {
throw new Error(message);
}
}
export default recipe(
Input,
Output,
(_state) => {
const html = `
`;
const turndown = new TurndownService({
headingStyle: "atx",
codeBlockStyle: "fenced",
emDelimiter: "*",
});
// test turndown
const parsed = turndown.turndown(html);
assert(parsed.length > 0, "turndown parsed HTML");
return {
[NAME]: str`3P Test`,
[UI]: (
3P Test
),
};
},
);