v0.5.2
Python application / build (push) Waiting to run

Что то сделал
This commit is contained in:
Igor20264
2026-09-08 19:37:54 +03:00
parent 1a5b35eb54
commit 510f7e7adf
90 changed files with 11720 additions and 5547 deletions
+17 -2
View File
@@ -39,6 +39,21 @@ def entries_from_text(text: str) -> list[BiblioEntry]:
return entries
# After citation linking, `[5]: …` often becomes `[]: …` in paragraph.text
# (the digits live in a hyperlink). Still a biblio source line to drop.
BIBLIO_RESIDUE_RE = re.compile(r"^\[\d*(?:\.\d+)?\]:\s*\S")
def is_biblio_source_paragraph(text: str) -> bool:
"""True if paragraph is a [n]: / []: bibliography source line (or empty)."""
stripped = (text or "").strip()
if not stripped:
return True
if entries_from_text(stripped):
return True
return bool(BIBLIO_RESIDUE_RE.match(stripped))
def extract_bibliography_from_markdown(md: str) -> list[BiblioEntry] | list[tuple[str, list[BiblioEntry]]]:
"""
Parse bibliography from raw markdown (reliable even if Marko merges lines).
@@ -126,8 +141,8 @@ def fold_bibliography(renderables: list[Renderable], parent,
consumed += 1
continue
if isinstance(item, Paragraph):
text = (item._docx_paragraph.text or "").strip()
if entries_from_text(text) or (not text):
text = item._docx_paragraph.text or ""
if is_biblio_source_paragraph(text):
consumed += 1
continue
break