Temporarily disable PDF parsing - use placeholder content until pdf-parse issue is resolved
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import multer from 'multer'
|
||||
import fs from 'fs/promises'
|
||||
import path from 'path'
|
||||
import { createRequire } from 'module'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const pdfParse = require('pdf-parse')
|
||||
|
||||
// Multer-Konfiguration für PDF-Uploads
|
||||
const storage = multer.diskStorage({
|
||||
@@ -55,12 +51,15 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
// PDF-Text extrahieren
|
||||
const pdfBuffer = await fs.readFile(file.path)
|
||||
const pdfData = await pdfParse.default(pdfBuffer)
|
||||
|
||||
// Text in HTML-Format konvertieren (einfache Formatierung)
|
||||
const htmlContent = convertTextToHtml(pdfData.text)
|
||||
// Für jetzt: Einfacher Platzhalter-Text statt PDF-Parsing
|
||||
// TODO: PDF-Parsing später implementieren
|
||||
const htmlContent = `
|
||||
<h2>Satzung</h2>
|
||||
<p>Die Satzung wurde erfolgreich hochgeladen.</p>
|
||||
<p><strong>Datei:</strong> ${file.originalname}</p>
|
||||
<p><strong>Größe:</strong> ${(file.size / 1024).toFixed(2)} KB</p>
|
||||
<p><em>Hinweis: Der Text-Inhalt wird automatisch extrahiert, sobald das PDF-Parsing implementiert ist.</em></p>
|
||||
`
|
||||
|
||||
// Config aktualisieren
|
||||
const configPath = 'server/data/config.json'
|
||||
@@ -88,16 +87,17 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
})
|
||||
|
||||
function convertTextToHtml(text) {
|
||||
// Einfache Text-zu-HTML-Konvertierung
|
||||
let html = text
|
||||
.replace(/\n\n+/g, '</p><p>') // Absätze
|
||||
.replace(/\n/g, '<br>') // Zeilenumbrüche
|
||||
.replace(/^(.+)$/gm, '<p>$1</p>') // Alle Zeilen in Paragraphen
|
||||
|
||||
// Überschriften erkennen (einfache Heuristik)
|
||||
html = html.replace(/<p>(§\s*\d+.*?)<\/p>/g, '<h3>$1</h3>')
|
||||
html = html.replace(/<p>(\d+\.\s+.*?)<\/p>/g, '<h4>$1</h4>')
|
||||
|
||||
return `<h2>Satzung</h2>${html}`
|
||||
}
|
||||
// TODO: PDF-Parsing-Funktion später implementieren
|
||||
// function convertTextToHtml(text) {
|
||||
// // Einfache Text-zu-HTML-Konvertierung
|
||||
// let html = text
|
||||
// .replace(/\n\n+/g, '</p><p>') // Absätze
|
||||
// .replace(/\n/g, '<br>') // Zeilenumbrüche
|
||||
// .replace(/^(.+)$/gm, '<p>$1</p>') // Alle Zeilen in Paragraphen
|
||||
//
|
||||
// // Überschriften erkennen (einfache Heuristik)
|
||||
// html = html.replace(/<p>(§\s*\d+.*?)<\/p>/g, '<h3>$1</h3>')
|
||||
// html = html.replace(/<p>(\d+\.\s+.*?)<\/p>/g, '<h4>$1</h4>')
|
||||
//
|
||||
// return `<h2>Satzung</h2>${html}`
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user