Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-17 02:16:42 +00:00
co-authored by renee-png
parent 3297d6efea
commit 772643f175
+4 -3
View File
@@ -46,9 +46,10 @@ function tokenize(node: Node, style: Style, out: Token[]) {
el.childNodes.forEach((c) => tokenize(c, next, out));
}
function alignOf(el: Element): Block extends { align: infer A } ? A : never {
type Align = "left" | "center" | "right" | "justify";
function alignOf(el: Element): Align {
const ta = (el.getAttribute("style") || "").match(/text-align:\s*(left|center|right|justify)/i)?.[1]?.toLowerCase();
return (ta as any) || "left";
return (ta as Align) || "left";
}
function htmlToBlocks(html: string): Block[] {
@@ -237,7 +238,7 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string
: (input.body || "").split("\n").map<Block>((line) => ({ kind: "para", align: "left", tokens: [{ text: line, style: {} }] }));
for (const block of blocks) {
if (block.kind === "spacer") { y += LINE_H; continue; }
if (block.kind === "spacer" || block.kind === "rule") { y += LINE_H; continue; }
if (block.kind === "list-item") {
const indent = 24 + block.level * 24;