refactor: rename yomitoku output to document.md for consistency
Normalizes the OCR output filename to document.md after finding it, matching pdftotext output naming. Keeps paths clean in cache and LLM context. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6f71bd4b4e
commit
1008ad0d30
1 changed files with 7 additions and 1 deletions
|
|
@ -697,12 +697,18 @@ func (al *AgentLoop) ocrPDF(
|
||||||
// Keep: .md files, figures/ directory (referenced by markdown output).
|
// Keep: .md files, figures/ directory (referenced by markdown output).
|
||||||
cleanupOCRPageImages(outputDir, pdfPath)
|
cleanupOCRPageImages(outputDir, pdfPath)
|
||||||
|
|
||||||
// Find the output markdown file
|
// Find the output markdown file and normalize its name to document.md
|
||||||
mdPath := findOCROutput(outputDir, pdfPath)
|
mdPath := findOCROutput(outputDir, pdfPath)
|
||||||
if mdPath == "" {
|
if mdPath == "" {
|
||||||
logger.WarnCF("agent", "OCR output not found", map[string]any{"output_dir": outputDir})
|
logger.WarnCF("agent", "OCR output not found", map[string]any{"output_dir": outputDir})
|
||||||
return fmt.Sprintf("[file:%s]", pdfPath)
|
return fmt.Sprintf("[file:%s]", pdfPath)
|
||||||
}
|
}
|
||||||
|
canonical := filepath.Join(outputDir, "document.md")
|
||||||
|
if mdPath != canonical {
|
||||||
|
if renameErr := os.Rename(mdPath, canonical); renameErr == nil {
|
||||||
|
mdPath = canonical
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Read preview from first part of the markdown
|
// Read preview from first part of the markdown
|
||||||
mdData, err := os.ReadFile(mdPath)
|
mdData, err := os.ReadFile(mdPath)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue