[Docs] Build document rendering page at /paper/{id} with full pipeline

← All Specs

Goal

Build a /paper/{id} page that renders authored papers with dynamic artifact embeds — replacing {{artifact:ID[:view]}} markers with rich HTML cards based on artifact type.

Context

SciDEX agents produce authored papers that embed live references to other artifacts (hypotheses, figures, datasets, dashboards). These embeds need to be rendered as interactive HTML previews, not raw text markers.

Implementation

API Endpoints

  • GET /api/papers/authored — list authored papers with status filtering (merged PR a12380300)
  • GET /api/papers/authored/{paper_id} — paper details with metadata and content; ?rendered=true resolves embeds

Embed Resolution Pipeline

  • _resolve_authored_paper_embeds(db, content) — finds all {{artifact:ID[:view]}} markers in paper content and replaces them with rendered HTML via _render_artifact_embed_html(db, embed_id, view)
  • _render_artifact_embed_html(db, embed_id, view="default") — renders typed HTML per artifact type:
- hypothesis → hypothesis card with title, score badge, target gene, description excerpt
- figure → figure with inline SVG or image, caption
- tabular_dataset → sortable HTML table (first 20 rows, up to 8 columns)
- dashboard → rendered dashboard live cards
- dataset → dataset card with source, row count, external link
- default → generic artifact card with title, type, link
- missing artifact → graceful error placeholder (red-bordered box with ID)

Page Route

GET /paper/{paper_id:path} — full paper page with:

  • Breadcrumb navigation (Home → Papers → Paper Title)
  • Paper header: title, SciDEX attribution, creation date, abstract, authors, embedded artifact ID badges
  • Body: markdown-rendered content with artifact embeds resolved inline
  • Fallback: handles /paper/{pmid} for imported papers (looks up via resolve_paper_id())

Acceptance Criteria

/paper/{id} returns rendered HTML for authored papers
{{artifact:HYPOTHESIS_ID:summary}} markers render as hypothesis cards
{{artifact:FIGURE_ID:figure}} markers render as figures
{{artifact:DATASET_ID:table}} markers render as data tables
☑ Missing artifacts show graceful placeholder, not broken markup
/paper/{pmid} fallback works for imported papers with figure extraction

Work Log

  • 2026-04-04: Implemented full pipeline (commit e717257ea). Created _render_artifact_embed_html, _resolve_authored_paper_embeds, and /paper/{paper_id:path} route. Added API endpoints /api/papers/authored and /api/papers/authored/{paper_id}. Verified 3/3 artifact markers resolved correctly in test papers. All acceptance criteria met.

Tasks using this spec (1)
[Docs] Build document rendering page at /paper/{id} with ful
done P93
File: sci-doc-02-RENDER_document_render_page_spec.md
Modified: 2026-04-25 22:00
Size: 3.0 KB