@@ -47,6 +47,7 @@ async function getArticleText(element: HTMLElement): Promise<string> {
4747 const clonedElement = element . cloneNode ( true ) as HTMLElement ;
4848
4949 clonedElement . querySelectorAll ( 'table' ) . forEach ( ( node ) => {
50+ // eslint-disable-next-line no-param-reassign
5051 node . textContent = htmlTableToPlainText ( node ) ;
5152 } ) ;
5253
@@ -102,22 +103,22 @@ function htmlTableToPlainText(tableElement: HTMLTableElement): string {
102103 const rowLength =
103104 columnWidths . reduce ( ( sum , columnWidth ) => sum + columnWidth ) +
104105 columnSeparator . length * ( columnWidths . length - 1 ) ;
105- const separator = `\n${ '─' . repeat ( rowLength ) } \n` ;
106+ const rowSeparator = `\n${ '─' . repeat ( rowLength ) } \n` ;
106107
107108 return rowsLines
108109 . flatMap ( ( row ) => {
109110 const rowHeight = Math . max ( ...row . map ( ( text ) => text . split ( '\n' ) . length ) ) ;
110111
111- return Array . from ( { length : rowHeight } , ( _ , lineIndex ) => {
112- return row
112+ return Array . from ( { length : rowHeight } , ( _ , lineIndex ) =>
113+ row
113114 . map ( ( cell , columnIndex ) => {
114115 const lineText = cell . split ( '\n' ) [ lineIndex ] ?? '' ;
115116 return lineText . padEnd ( columnWidths [ columnIndex ] , '\xa0' ) ; //
116117 } )
117- . join ( columnSeparator ) ;
118- } ) . join ( '\n' ) ;
118+ . join ( columnSeparator ) ,
119+ ) . join ( '\n' ) ;
119120 } )
120- . join ( separator ) ;
121+ . join ( rowSeparator ) ;
121122}
122123
123124function wrapText ( text : string , maxLineLength : number ) : string {
0 commit comments