AFFiNE/tools/copilot-result/markdown.js
2024-11-01 07:05:12 +00:00

26 lines
604 B
JavaScript

import { jsxslack } from 'jsx-slack';
import { marked, Renderer } from 'marked';
export const render = markdown => {
const rendered = marked(markdown, {
renderer: new (class CustomRenderer extends Renderer {
heading({ tokens }) {
return `
<Fragment>
<Section><b>${tokens[0].text}</b></Section>
<Divider />
</Fragment>`;
}
list(token) {
return `<Section>${super.list(token)}</Section>`;
}
hr() {
return `<Divider />`;
}
})(),
});
return jsxslack([`<Blocks>${rendered}</Blocks>`]);
};