Skip to content

Feat: auto-number figure and table captions - #8

Open
mahdyarief wants to merge 1 commit into
amitdevx:mainfrom
mahdyarief:feat/auto-captions
Open

mahdyarief wants to merge 1 commit into
amitdevx:mainfrom
mahdyarief:feat/auto-captions

Conversation

@mahdyarief

Copy link
Copy Markdown

Summary

  • md2pdf emits plain <p><img></p> and <table> markup with no semantic figure/table wrapper, which makes CSS-only captioning impossible.
  • New rehype plugin src/plugins/layout/captions.ts wraps bare <img> and <table> nodes in <figure><...><figcaption>. Numbering is driven by CSS counters (so it stays correct across page breaks).
  • Opt-in via --figure-captions / --table-captions (or the captions config option). Defaults: Gambar for figures, Tabel for tables (labels configurable).
  • Also fixes a pipeline cache-key bug: the processor cache did not include captions in its key, so the option was ignored on the second document when the first had set it.

Test plan

  • tests/contract/captions.test.ts (4 cases: figure wrap, table wrap, disabled no-op, figures-only mode)
  • Full suite green: 175 passed / 9 skipped (with both PRs applied)

🤖 Generated with Claude Code

…e-captions)

md2pdf emits plain <p><img></p> and <table> markup with no semantic
figure/table wrapper, making CSS-only captioning impossible. This adds a
rehype plugin (src/plugins/layout/captions.ts) that wraps bare <img> and
<table> nodes in <figure><...><figcaption>, with numbering driven by CSS
counters (so it stays correct across page breaks).

Opt-in via --figure-captions / --table-captions (or the captions config
option). Also fixes a pipeline cache-key bug: the processor cache did not
include captions in its key, so the option was ignored on the second
document when the first had set it.

Covered by tests/contract/captions.test.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant