Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
9a373f9a01
commit
2a2b543d8f
+37
-25
@@ -62,38 +62,53 @@ function htmlToBlocks(html: string): Block[] {
|
||||
|
||||
const walkList = (listEl: Element, ordered: boolean, level: number) => {
|
||||
let idx = 1;
|
||||
listEl.querySelectorAll(":scope > li").forEach((li) => {
|
||||
const tokens: Token[] = [];
|
||||
li.childNodes.forEach((child) => {
|
||||
if (child.nodeType === Node.ELEMENT_NODE && /^(ul|ol)$/i.test((child as Element).tagName)) return;
|
||||
tokenize(child, {}, tokens);
|
||||
Array.from(listEl.children)
|
||||
.filter((child): child is Element => child.tagName.toLowerCase() === "li")
|
||||
.forEach((li) => {
|
||||
const tokens: Token[] = [];
|
||||
li.childNodes.forEach((child) => {
|
||||
if (child.nodeType === Node.ELEMENT_NODE && /^(ul|ol)$/i.test((child as Element).tagName)) return;
|
||||
tokenize(child, {}, tokens);
|
||||
});
|
||||
out.push({ kind: "list-item", ordered, level, index: idx++, tokens });
|
||||
Array.from(li.children)
|
||||
.filter((child): child is Element => /^(ul|ol)$/i.test(child.tagName))
|
||||
.forEach((nested) => walkList(nested, nested.tagName.toLowerCase() === "ol", level + 1));
|
||||
});
|
||||
out.push({ kind: "list-item", ordered, level, index: idx++, tokens });
|
||||
li.querySelectorAll(":scope > ul").forEach((n) => walkList(n as Element, false, level + 1));
|
||||
li.querySelectorAll(":scope > ol").forEach((n) => walkList(n as Element, true, level + 1));
|
||||
});
|
||||
};
|
||||
|
||||
Array.from(root.children).forEach((el) => {
|
||||
const tag = el.tagName.toLowerCase();
|
||||
if (tag === "ul") return walkList(el, false, 0);
|
||||
if (tag === "ol") return walkList(el, true, 0);
|
||||
const walk = (node: Element) => {
|
||||
const tag = node.tagName.toLowerCase();
|
||||
if (tag === "ul") return walkList(node, false, 0);
|
||||
if (tag === "ol") return walkList(node, true, 0);
|
||||
if (tag === "blockquote") {
|
||||
const tokens: Token[] = [];
|
||||
el.childNodes.forEach((c) => tokenize(c, {}, tokens));
|
||||
out.push({ kind: "para", align: alignOf(el), tokens, indent: 36 });
|
||||
node.childNodes.forEach((c) => tokenize(c, {}, tokens));
|
||||
out.push({ kind: "para", align: alignOf(node), tokens, indent: 36 });
|
||||
return;
|
||||
}
|
||||
if (tag === "h1" || tag === "h2" || tag === "h3") {
|
||||
const tokens: Token[] = [];
|
||||
el.childNodes.forEach((c) => tokenize(c, { bold: true }, tokens));
|
||||
out.push({ kind: "para", align: alignOf(el), tokens });
|
||||
node.childNodes.forEach((c) => tokenize(c, { bold: true }, tokens));
|
||||
out.push({ kind: "para", align: alignOf(node), tokens });
|
||||
return;
|
||||
}
|
||||
if (tag === "p") {
|
||||
const tokens: Token[] = [];
|
||||
node.childNodes.forEach((c) => tokenize(c, {}, tokens));
|
||||
out.push({ kind: "para", align: alignOf(node), tokens });
|
||||
return;
|
||||
}
|
||||
if (tag === "div" || tag === "section" || tag === "article") {
|
||||
Array.from(node.children).forEach((child) => walk(child));
|
||||
return;
|
||||
}
|
||||
const tokens: Token[] = [];
|
||||
el.childNodes.forEach((c) => tokenize(c, {}, tokens));
|
||||
out.push({ kind: "para", align: alignOf(el), tokens });
|
||||
});
|
||||
node.childNodes.forEach((c) => tokenize(c, {}, tokens));
|
||||
if (tokens.length > 0) out.push({ kind: "para", align: alignOf(node), tokens });
|
||||
};
|
||||
|
||||
Array.from(root.children).forEach((el) => walk(el));
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -197,7 +212,6 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string
|
||||
const leftColW = CONTENT_W * 0.58;
|
||||
const leftX = MARGIN;
|
||||
const rightX = MARGIN + leftColW + 24;
|
||||
const captionRightEdge = MARGIN + CONTENT_W;
|
||||
const labelIndent = 24; // ~1/3" indent for "Plaintiff(s)," / "Defendant(s)."
|
||||
|
||||
const plaintiffLines = (input.plaintiffs || "").split("\n").filter((l) => l.trim());
|
||||
@@ -230,10 +244,8 @@ export async function downloadPleadingPdf(input: PleadingInput, filename: string
|
||||
|
||||
const captionEndY = ly;
|
||||
pdf.setLineWidth(0.6);
|
||||
// Vertical divider between caption columns
|
||||
pdf.line(MARGIN + leftColW + 12, captionStartY - LINE_H + 4, MARGIN + leftColW + 12, captionEndY);
|
||||
// Bottom border spanning BOTH caption cells (full content width)
|
||||
pdf.line(leftX, captionEndY + 2, captionRightEdge, captionEndY + 2);
|
||||
// Bottom border only under the left caption cell
|
||||
pdf.line(leftX, captionEndY + 2, MARGIN + leftColW + 12, captionEndY + 2);
|
||||
|
||||
y = captionEndY + LINE_H;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user