Skip to content

Commit b05fd13

Browse files
committed
feat: support paragraph AND search and stabilize translation display
1 parent c8d2f3b commit b05fd13

3 files changed

Lines changed: 56 additions & 22 deletions

File tree

‎server/document-search.test.mjs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import {searchSegments} from '../src/document-search.mjs';
44
test('PDF search spans text runs, ignores layout whitespace, and keeps matching coordinates',()=>{
55
const a={x:10,y:20,width:30,height:12},b={x:40,y:20,width:30,height:12};
66
const segments=[{text:'Hello ',box:a},{text:'WORLD',box:b},{text:'hello world',box:a}];
7-
assert.deepEqual(searchSegments(segments,'hello world').map(m=>m.boxes),[[a,b],[a]]);
7+
assert.deepEqual(searchSegments(segments,'helloworld').map(m=>m.boxes),[[a,b],[a]]);
88
assert.equal(searchSegments([{text:'译 文A',box:a}],'译文a').length,1);
99
assert.deepEqual(searchSegments(segments,' '),[]);
10+
const first={},second={};
11+
const paragraphs=[{text:'2017: other words ',box:a,block:first},{text:'Miller',box:b,block:first},{text:'Miller only',box:a,block:second}];
12+
assert.deepEqual(searchSegments(paragraphs,'Miller 2017').map(m=>m.boxes),[[a,b]]);
13+
assert.equal(searchSegments(paragraphs,'2017 Miller Miller').length,1);
14+
assert.equal(searchSegments([{text:'Miller',box:a,block:first},{text:'2017',box:b,block:second}],'Miller 2017').length,0);
15+
1016
});

0 commit comments

Comments
 (0)