添加期刊引用分析
This commit is contained in:
40
scripts/test-ref-comment.mjs
Normal file
40
scripts/test-ref-comment.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
import {
|
||||
Document,
|
||||
Paragraph,
|
||||
TextRun,
|
||||
CommentRangeStart,
|
||||
CommentRangeEnd,
|
||||
CommentReference,
|
||||
LevelFormat,
|
||||
LevelSuffix,
|
||||
AlignmentType,
|
||||
Packer
|
||||
} from 'docx';
|
||||
import JSZip from 'jszip';
|
||||
import fs from 'fs';
|
||||
import { buildBookAmaAuthorComment } from '../src/utils/referenceAuthorAma.js';
|
||||
import { buildManuscriptWordDocument } from '../src/utils/exportManuscriptWord.js';
|
||||
|
||||
const ref = {
|
||||
refer_type: 'book',
|
||||
author: 'Jacqueline Fawcett, Susan DeSanto-Madeya',
|
||||
title: 'Contemporary Nursing Knowledge',
|
||||
dateno: '(3rd Edition). Philadelphia, PA: F. A. Davis Company; 2013.',
|
||||
isbn: '978-0-8036-2765-9'
|
||||
};
|
||||
|
||||
console.log('comment text:', buildBookAmaAuthorComment(ref));
|
||||
|
||||
const doc = buildManuscriptWordDocument([], '', [ref], null, null);
|
||||
const buf = await Packer.toBuffer(doc);
|
||||
fs.writeFileSync('test-ref-comment.docx', buf);
|
||||
|
||||
const zip = await JSZip.loadAsync(buf);
|
||||
const docXml = await zip.file('word/document.xml').async('string');
|
||||
const commentsXml = zip.file('word/comments.xml');
|
||||
console.log('has comments.xml:', !!commentsXml);
|
||||
console.log('has commentReference:', docXml.includes('commentReference'));
|
||||
console.log('has commentRangeStart:', docXml.includes('commentRangeStart'));
|
||||
if (commentsXml) {
|
||||
console.log('comments preview:', (await commentsXml.async('string')).slice(0, 500));
|
||||
}
|
||||
Reference in New Issue
Block a user