fix: correct UPDATEABLE_PATHS repo paths; plugin install uses vault-first source; exclude table images from figure-map matching

This commit is contained in:
Research Assistant 2026-04-28 23:58:02 +08:00
parent 2eaeb30efa
commit 0d2c16172f
4 changed files with 29 additions and 13 deletions

View file

@ -1,3 +1,3 @@
"""paperforge — PaperForge package."""
__version__ = "1.4.5"
__version__ = "1.4.6"

View file

@ -699,17 +699,27 @@ def build_figure_map(fulltext: str, zotero_key: str = "") -> dict:
caption_text = m.group(2).strip() if len(m.groups()) > 1 else ""
# Find nearest image within window of adjacent pages (current ± 2 pages)
# Filter: figure captions → exclude table images; table captions → prefer table images
best_image = None
min_distance = float("inf")
is_table_type = entry_type in ("main_table", "supplementary_table")
for img in all_images:
# Check if image is within 2 pages of current page
img_name_lower = img.get("link", "").lower()
img_is_table = "table" in img_name_lower
# Figure captions: skip images that are clearly table screenshots
if not is_table_type and img_is_table:
continue
if current_page is not None and img["page"] is not None:
page_diff = abs(img["page"] - current_page)
if page_diff <= 2:
distance = abs(img["line_idx"] - idx)
if distance < min_distance:
min_distance = distance
# Table captions: boost score for table images (+ priority)
score = distance - 100 if (is_table_type and img_is_table) else distance
if score < min_distance:
min_distance = score
best_image = img
# Find additional images on the same page near the best image

View file

@ -498,4 +498,4 @@ def run_status(vault: Path, verbose: bool = False, json_output: bool = False) ->
GITHUB_REPO = "LLLin000/PaperForge"
GITHUB_ZIP = f"https://github.com/{GITHUB_REPO}/archive/refs/heads/master.zip"
UPDATEABLE_PATHS = ["skills", "pipeline", "command", "scripts", "plugin"]
UPDATEABLE_PATHS = ["command", "scripts", "paperforge/skills", "paperforge/plugin"]

View file

@ -216,17 +216,23 @@ def update_via_zip(vault: Path) -> bool:
def _install_obsidian_plugin(vault: Path) -> bool:
"""Copy Obsidian plugin files into .obsidian/plugins/paperforge/."""
try:
import importlib
import paperforge
importlib.reload(paperforge)
"""Copy Obsidian plugin files into .obsidian/plugins/paperforge/.
pkg_dir = Path(paperforge.__file__).parent.resolve()
plugin_src = pkg_dir / "plugin"
Source priority: vault copy (git/zip) Python package (pip).
"""
try:
plugin_dst = vault / ".obsidian" / "plugins" / "paperforge"
if not plugin_src.exists() or not plugin_src.is_dir():
# Try vault copy first (works for git pull and zip updates)
plugin_src = vault / "paperforge" / "plugin"
if not plugin_src.is_dir():
# Fallback: Python package location (works for pip)
import importlib
import paperforge
importlib.reload(paperforge)
plugin_src = Path(paperforge.__file__).parent.resolve() / "plugin"
if not plugin_src.is_dir():
logger.warning("Plugin source not found: %s", plugin_src)
return False