assert(text===fixture.highlightText,'highlight must contain only the exact cited quotation')
}
})
}
finished.value=true
return
}
for(constfixtureof[
{name:'citation anchor retains all sentences preceding the marker',html:'<p>第一句说明原目录保留文件。第二句说明回到主仓库开发。<span class="citation">[1]</span></p>',want:'第一句说明原目录保留文件。第二句说明回到主仓库开发。'},
{name:'citation anchor stops at the previous citation',html:'<p>先前的内容属于另一个来源。<span class="citation">[1]</span>本条引用包括操作原理。以及后续开发所在的目录。<span class="citation">[2]</span></p>',want:'本条引用包括操作原理。以及后续开发所在的目录。'},
{name:'adjacent citations share the same preceding passage',html:'<p>两个来源共同支撑这段完整的解释。<span class="citation">[1]</span> <span class="citation">[2]</span></p>',want:'两个来源共同支撑这段完整的解释。'},
awaitrunOther('DOCX rejects a different image identity',awaitdocxImageFixture(),'docx',{imageDigest:'0'.repeat(64)},r=>assert(!r.found,JSON.stringify(r)))
constfenced='# Source document\n\nOpening unrelated paragraph.\n\n- **Explanation**: Releasing the branch preserves the current commit and files.\n\n```bash\ngit -C /example/tree switch --detach\n```'
// Manual/clipped documents have no source_locators. Match their raw chunk
// Markdown against the complete document returned by the preview endpoint.
constmanualChunk='| Model | Flagged as AI | Judged human |\n| --- | --- | --- |\n| v2 | 11 / 210 (5%) | 95% |\n\nFlagged less than half as often as the previous release.'
constmanualDocument='# Model card\n\n'+'Unrelated introduction.\n\n'.repeat(60)+manualChunk+'\n\nUnrelated appendix.'
awaitrunOther('Manual Markdown without locators highlights the cited table and paragraph and scrolls to them',newBlob([manualDocument]),'md',manualRequest,r=>{
assert(r.found&&r.precise,JSON.stringify(r))
consttext=highlightedText()
assert(text.includes('11 / 210 (5%)')&&text.includes('95%')&&text.includes('Flagged less than half'),text)
assert(!text.includes('Unrelated'),'unrelated paragraphs must not be highlighted')
awaitrunOther('Markdown fenced language is not treated as visible evidence',newBlob([fenced]),'md',{sourceMarkdown:fenced},r=>assert(r.found&&r.precise,JSON.stringify(r)))
awaitrunOther('Markdown paraphrase narrows within its verified source block',newBlob([fenced]),'md',{sourceMarkdown:fenced,sentence:'This operation preserves the current commit and files, freeing the branch.'},r=>{
assert(r.found&&!r.precise,JSON.stringify(r))
assert(highlightedText()==='Explanation: Releasing the branch preserves the current commit and files',highlightedText())
})
awaitrunOther('Markdown exact code citation narrows to the command',newBlob([fenced]),'md',{sourceMarkdown:fenced,sentence:'git -C /example/tree switch --detach'},r=>{
awaitrunOther('Markdown missing scope cannot match a similar paragraph',newBlob([fenced]),'md',{sourceMarkdown:fenced+'\nMissing required evidence.',sentence:'preserves the current commit and files'},r=>assert(!r.found,JSON.stringify(r)))
consthtmlCode='Literal code: `<Widget>` and `x < 1.5`.\n\n~~~html\n<section>example</section>\n~~~'
awaitrunOther('Markdown literal tags and tilde code fences survive projection',newBlob([htmlCode]),'md',{sourceMarkdown:htmlCode},r=>assert(r.precise,JSON.stringify(r)))
awaitrunOther('Markdown changed numeric evidence is rejected',newBlob([htmlCode]),'md',{sourceMarkdown:htmlCode.replace('1.5','15')},r=>assert(!r.found,JSON.stringify(r)))
awaitrunOther('Markdown child starting mid-paragraph restores its opening without the next paragraph',newBlob([boundaryDocument]),'md',{
sourceMarkdown:'Tokens stay in the local keychain and never sync to the cloud.',sentence:'Credentials stay in the local keychain with no cloud synchronization.',
constrepeatedBoundary='# First occurrence\n\n'+boundaryParagraph+'\n\n# Second occurrence\n\n'+boundaryParagraph
awaitrunOther('Markdown verified scope preserves the occurrence of a repeated paragraph',newBlob([repeatedBoundary]),'md',{
sourceMarkdown:'# Second occurrence\n\nClient only uses `api.example.test`',sentence:'Use api.example.test for read-only requests and keep tokens in the local keychain.',
awaitrunOther('DOCX verifies the indexed paragraph',docx,'docx',{locators:[{type:'docx',mapping:'exact',block:2,quote:'The cited limit is 1.5 millimeters.'}]},r=>assert(r.precise,JSON.stringify(r)))
awaitrunOther('DOCX revalidates a legacy wrong block',docx,'docx',{scope:'The cited limit is 1.5 millimeters.',locators:[{type:'docx',block:1}]},r=>assert(r.precise,JSON.stringify(r)))
awaitrunOther('DOCX rejects a different numeric value',docx,'docx',{scope:'The cited limit is 15 millimeters.',locators:[{type:'docx',block:2}]},r=>assert(!r.found,JSON.stringify(r)))
awaitrunOther('DOCX partial locator still verifies the exact cited sentence',docx,'docx',{
scope:'The cited limit is 1.5 millimeters. Unmapped image placeholder.',sentence:'The cited limit is 1.5 millimeters.',
locators:[{type:'docx',mapping:'exact',partial:true,block:2,quote:'The cited limit is 1.5 millimeters.'}],
},r=>assert(r.precise,JSON.stringify(r)))
constimageContext={before:'The cited limit is 1.5 millimeters.',after:'Verified paragraph after the image.'}
awaitrunOther('DOCX OCR citation highlights its unique bracketed image',awaitdocxImageFixture(),'docx',{imageContext},r=>{
awaitrunOther('DOCX multiple bracketed images cannot silently choose the first',awaitdocxImageFixture(2),'docx',{imageContext},r=>assert(!r.found,JSON.stringify(r)))
awaitrunOther('DOCX missing image context cannot highlight another image',awaitdocxImageFixture(),'docx',{imageContext:{...imageContext,after:'Missing paragraph.'}},r=>assert(!r.found,JSON.stringify(r)))
awaitrunOther('DOCX image at chunk end stops before the next original paragraph',awaitdocxImageFixture(),'docx',{imageContext:{...imageContext,after:''}},r=>assert(r.found&&!r.precise,JSON.stringify(r)))
awaitrunOther('DOCX image at chunk start uses its following original paragraph',awaitdocxImageFixture(),'docx',{imageContext:{...imageContext,before:''}},r=>assert(r.found&&!r.precise,JSON.stringify(r)))
constsheet=sheetFixture()
awaitrunOther('spreadsheet shows verified rows as a region',sheet,'xlsx',{locators:[{type:'sheet',mapping:'exact',sheet:'Inspection',row_start:2,row_end:2,quote:'Anchor 1.5 mm'}]},r=>{
awaitrunOther('EPUB legacy duplicates cannot choose first chapter',epub,'epub',{scope:'Repeated cited passage.',locators:[{type:'section',section:1}]},r=>assert(!r.found,JSON.stringify(r)))
awaitrunOther('Markdown repeated evidence is not silently selected',newBlob(['First chapter.\n\nRepeated cited passage.\n\nSecond chapter.\n\nRepeated cited passage.']),'md',{scope:'Repeated cited passage.'},r=>assert(!r.found,JSON.stringify(r)))
awaitrunOther('plain text revalidates stale character offsets',newBlob(['Wrong opening.\nUnique cited passage.']),'txt',{scope:'Unique cited passage.',locators:[{type:'text',start:0,end:10,quote:'Unique cited passage.'}]},r=>assert(r.precise,JSON.stringify(r)))
awaitrunOther('edited evidence cannot reuse an original text location',newBlob(['Unique cited passage.']),'txt',{unavailable:true,scope:'Unique cited passage.'},r=>assert(!r.found&&r.reason==='unavailable',JSON.stringify(r)))
otherBlob.value=null
awaitrun('legacy wrong page resolves to page 2',[
{lines:[['Unrelated first page.',60,620]]},{lines:[['Unique cited source passage.',60,620]]},
awaitrun('table columns verify repeated course names against the paired teacher rows',[
{lines:[['Drawing Bob RoomA',60,650],['Drawing Alice RoomB',60,620],['Robotics Carol RoomC',60,590],['Dance David RoomD',60,560],['Music Ellen RoomE',60,530],['Chess Frank RoomF',60,500]]},
{lines:[['Drawing Alice RoomA',60,650],['Drawing Bob RoomB',60,620],['Robotics Carol RoomC',60,590],['Dance David RoomD',60,560],['Music Ellen RoomE',60,530],['Chess Frank RoomF',60,500]]},
],{scope:'|Drawing Drawing Robotics Dance Music Chess|Alice Bob Carol David Ellen Frank|'},r=>{
{lines:[['Step two: choose the desktop view.',60,650]]},
{lines:[['Step three: open the application.',60,650],['Select the application form.',60,600]]},
],{scope:'Step two: choose the desktop view.\nStep three: open the application.\nSelect the application form.\n'+'Unmatched image OCR details. '.repeat(30),sentence:'Select the application form.'},r=>{
awaitrun('decimal mismatch has no highlight',[{lines:[['The limit is 15 millimeters.',60,620]]}],{scope:'The limit is 1.5 millimeters.'},(r)=>assert(!r.found&&!marks().length,JSON.stringify(r)))
awaitrun('bbox disambiguates the lower repeated paragraph',[{lines:[['Repeated source passage.',60,620],['Repeated source passage.',60,420]]}],{
awaitrun('cross-page evidence highlights both pages',[{lines:[['First half of the',60,620]]},{lines:[['source continues here.',60,620]]}],{scope:'First half of the source continues here.'},(r)=>{
zip.file('word/document.xml','<?xml version="1.0"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:r><w:t>Unrelated first paragraph.</w:t></w:r></w:p><w:p><w:r><w:t>The cited limit is 1.5 millimeters.</w:t></w:r></w:p></w:body></w:document>')
zip.file('word/document.xml',xml.replace('</w:body>',drawing.repeat(count)+'<w:p><w:r><w:t>Verified paragraph after the image.</w:t></w:r></w:p></w:body>'))
pdf+=`xref\n0 ${objects.length+1}\n0000000000 65535 f \n`
pdf+=offsets.slice(1).map((offset)=>`${String(offset).padStart(10,'0')} 00000 n \n`).join('')
pdf+=`trailer\n<< /Size ${objects.length+1} /Root 1 0 R >>\nstartxref\n${xref}\n%%EOF`
returnnewTextEncoder().encode(pdf).buffer
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.