@@ -258,7 +258,7 @@ describe("struct tree", function () {
258258 await loadingTask . destroy ( ) ;
259259 } ) ;
260260
261- it ( "parses structure with some MathML in MS Office specific entry" , async function ( ) {
261+ it ( "parses structure with some MathML in MS Office specific entry" , async function ( ) {
262262 const filename = "bug1937438_from_word.pdf" ;
263263 const params = buildGetDocumentParams ( filename ) ;
264264 const loadingTask = getDocument ( params ) ;
@@ -300,6 +300,34 @@ describe("struct tree", function () {
300300 } ,
301301 struct
302302 ) ;
303+ } ) ;
304+
305+ it ( "should collect all list and table items in StructTree" , async function ( ) {
306+ const findNodes = ( node , check ) => {
307+ const results = [ ] ;
308+ if ( check ( node ) ) {
309+ results . push ( node ) ;
310+ }
311+ if ( node . children ) {
312+ for ( const child of node . children ) {
313+ results . push ( ...findNodes ( child , check ) ) ;
314+ }
315+ }
316+ return results ;
317+ } ;
318+ const loadingTask = getDocument ( buildGetDocumentParams ( "issue20324.pdf" ) ) ;
319+
320+ const pdfDoc = await loadingTask . promise ;
321+ const page = await pdfDoc . getPage ( 1 ) ;
322+ const tree = await page . getStructTree ( {
323+ includeMarkedContent : true ,
324+ } ) ;
325+ const cells = findNodes ( tree , node => node . role === "TD" ) ;
326+ expect ( cells . length ) . toEqual ( 4 ) ;
327+
328+ const listItems = findNodes ( tree , node => node . role === "LI" ) ;
329+ expect ( listItems . length ) . toEqual ( 4 ) ;
330+
303331 await loadingTask . destroy ( ) ;
304332 } ) ;
305333} ) ;
0 commit comments