Difficulty and Topic Display Update
This commit is contained in:
+18
-2
@@ -92,14 +92,30 @@ export default class Typst {
|
||||
return result;
|
||||
}
|
||||
|
||||
async renderToImage(typstCode: string): Promise<string | null> {
|
||||
async renderToImage(typstCode: string, metadata?: { topic?: string; difficulty?: string }): Promise<string | null> {
|
||||
const metadataHeader = metadata ? `
|
||||
#align(center)[
|
||||
#block(
|
||||
fill: rgb("#e0f2fe"),
|
||||
inset: 10pt,
|
||||
radius: 4pt,
|
||||
[
|
||||
#text(weight: "bold", size: 14pt)[Topic: ${metadata.topic || "N/A"}] \
|
||||
#text(size: 12pt, fill: rgb("#64748b"))[Difficulty: ${metadata.difficulty || "N/A"}]
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
#v(0.8em)
|
||||
` : '';
|
||||
|
||||
const styledCode = `
|
||||
#set page(width: 210mm, height: auto, margin: (x: 20pt, y: 25pt), fill: white)
|
||||
#set text(size: 16pt, font: "New Computer Modern")
|
||||
#set par(justify: true, leading: 0.65em)
|
||||
#set block(spacing: 1.2em)
|
||||
|
||||
${typstCode}
|
||||
${metadataHeader}${typstCode}
|
||||
`;
|
||||
|
||||
const result = await this.compile(styledCode, { cleanup: false });
|
||||
|
||||
Reference in New Issue
Block a user