GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): separate wrapped EPUB nested lists from parent text (#43… · patroza/t3code@fbb6526

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/provider
    • documentTextWorker.ts
    • userInputAttachments.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/provider/documentTextWorker.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/documentTextWorker.ts
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ function* paragraphs(node: XmlNode): Generator<TextPart, void> {
323323
yield* text(child);
324324
yield "\n";
325325
} else {
326-
if (node.name === "li" && ["ol", "ul"].includes(child.name)) yield LINE_START;
326+
if (["ol", "ul", "dl"].includes(child.name)) {
327+
if (!child.hasText) continue;
328+
yield LINE_START;
329+
}
327330
yield* paragraphs(child);
328331
if (["li", "div", "section", "dt", "dd"].includes(child.name)) yield "\n";
329332
}
@@ -1120,7 +1123,7 @@ export async function extractDocumentText(path: string, extension: string): Prom
11201123
continue;
11211124
}
11221125
if (part === LINE_START) {
1123-
// A nested list starts its own line unless its parent item's text already ended one.
1126+
// A list starts its own line unless the text before it already ended one.
11241127
if (!midLine) continue;
11251128
part = "\n";
11261129
}
Collapse file

‎apps/server/src/provider/userInputAttachments.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/provider/userInputAttachments.test.ts
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,25 @@ describe("question answer paths", () => {
649649
Effect.gen(function* () {
650650
const config = yield* ServerConfig.ServerConfig;
651651
const cases = [
652+
{
653+
ext: "epub",
654+
bounded: true,
655+
parts: {
656+
"META-INF/container.xml": '<container><rootfile full-path="book.opf"/></container>',
657+
"book.opf":
658+
'<package><manifest><item id="chapter" href="chapter.xhtml" media-type="application/xhtml+xml"/></manifest><spine><itemref idref="chapter"/></spine></package>',
659+
"chapter.xhtml":
660+
'<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Guide</title></head><body><ol><li>Before boarding<div><ul><li>Check passports</li></ul></div></li></ol>Intro<ul><li>Read the checklist</li></ul><dl><dt>Visa</dt><dd>Requirements<ul><li>Photo</li></ul></dd></dl><div>Carry<dl><dt>Passport</dt><dd>Required</dd></dl></div><div>Leave <ul></ul>room</div><div>Keep <ul><li hidden="">Draft</li></ul>walking</div></body></html>',
661+
},
662+
expected: [
663+
"Before boarding\nCheck passports",
664+
"Intro\nRead the checklist",
665+
"Requirements\nPhoto",
666+
"Carry\nPassport\nRequired",
667+
"Leave room",
668+
"Keep walking",
669+
],
670+
},
652671
{
653672
ext: "epub",
654673
bounded: true,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.