30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
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 || ''));
|
|
});
|