document-conversion-assistant
Version:
A document conversion tool that maintains format and style consistency
58 lines (48 loc) โข 1.94 kB
JavaScript
// Simple test script to verify document conversion functionality
import fs from 'fs';
import path from 'path';
// Test basic file operations
console.log('๐งช Testing Document Conversion Assistant...');
// Check if test file exists
const testFile = './test.txt';
if (fs.existsSync(testFile)) {
console.log('โ
Test file exists:', testFile);
// Read test file content
const content = fs.readFileSync(testFile, 'utf8');
console.log('โ
File content read successfully');
console.log('๐ Content preview:', content.substring(0, 100) + '...');
// Test basic HTML conversion (simple approach)
const htmlContent = `<!DOCTYPE html>
<html>
<head>
<title>Converted Document</title>
</head>
<body>
<pre>${content}</pre>
</body>
</html>`;
// Write HTML output
const outputDir = './converted_documents';
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
console.log('โ
Output directory created:', outputDir);
}
const htmlFile = path.join(outputDir, 'test.html');
fs.writeFileSync(htmlFile, htmlContent);
console.log('โ
HTML conversion completed:', htmlFile);
// Test basic Markdown conversion
const markdownContent = `# Converted Document\n\n${content}`;
const mdFile = path.join(outputDir, 'test.md');
fs.writeFileSync(mdFile, markdownContent);
console.log('โ
Markdown conversion completed:', mdFile);
console.log('\n๐ Basic conversion functionality test completed successfully!');
console.log('๐ Check the converted_documents folder for output files.');
} else {
console.log('โ Test file not found:', testFile);
}
console.log('\n๐ Test Summary:');
console.log('- File reading: โ
');
console.log('- Directory creation: โ
');
console.log('- HTML conversion: โ
');
console.log('- Markdown conversion: โ
');
console.log('- Core functionality: Working!');