parser refactured WP15b
This commit is contained in:
1 parent
21cda0072a
commit
ecb35fb869
6 files changed
+8
-25
No files matched your search
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
FILE: app/core/parsing/parsing_scanner.py
|
||||
DESCRIPTION: Pre-Scan für den LocalBatchCache (Pass 1).
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
from typing import Optional
|
||||
from .parsing_models import NoteContext
|
||||
from .parsing_markdown import read_markdown
|
||||
|
||||
def pre_scan_markdown(path: str) -> Optional[NoteContext]:
|
||||
"""Extrahiert Identität und Kurz-Kontext zur Validierung."""
|
||||
parsed = read_markdown(path)
|
||||
if not parsed: return None
|
||||
fm = parsed.frontmatter
|
||||
note_id = str(fm.get("id") or os.path.splitext(os.path.basename(path))[0])
|
||||
clean_body = re.sub(r'[#*`>]', '', parsed.body[:600]).strip()
|
||||
summary = clean_body[:500] + "..." if len(clean_body) > 500 else clean_body
|
||||
return NoteContext(
|
||||
note_id=note_id,
|
||||
title=str(fm.get("title", note_id)),
|
||||
type=str(fm.get("type", "concept")),
|
||||
summary=summary,
|
||||
tags=fm.get("tags", []) if isinstance(fm.get("tags"), list) else []
|
||||
)
|
||||
Reference in new issue
Block a user