专刊
This commit is contained in:
29
scripts/test-extract-figures.mjs
Normal file
29
scripts/test-extract-figures.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import FS from 'fs';
|
||||
import path from 'path';
|
||||
import { JSDOM } from 'jsdom';
|
||||
|
||||
const { window } = new JSDOM('<!DOCTYPE html><html><body></body></html>');
|
||||
global.window = window;
|
||||
global.document = window.document;
|
||||
global.DOMParser = window.DOMParser;
|
||||
global.Node = window.Node;
|
||||
global.HTMLElement = window.HTMLElement;
|
||||
global.FileReader = window.FileReader;
|
||||
global.Blob = window.Blob;
|
||||
|
||||
const { parseWordFigures } = await import('../src/utils/wordFigureImport.js');
|
||||
|
||||
const filePath = path.join(
|
||||
'C:/Users/Administrator/Desktop/IN2026A0418001_final_20260713 1.docx'
|
||||
);
|
||||
const buf = FS.readFileSync(filePath);
|
||||
const result = await parseWordFigures(buf);
|
||||
console.log('parsedCount', result.parsedCount);
|
||||
result.figures.forEach((f, idx) => {
|
||||
console.log('----', idx + 1);
|
||||
console.log('num', f.figureNumber);
|
||||
console.log('title', f.title.slice(0, 130));
|
||||
console.log('note', (f.note || '').slice(0, 150));
|
||||
console.log('imgs', f.imageCount);
|
||||
console.log('red', /data-word-caption-color="red"|#d25a5a/i.test(f.titleHtml || ''));
|
||||
});
|
||||
Reference in New Issue
Block a user