Skip to content

feat: add renderLatexPDF subprocess renderer - #40

Merged
rohitm-1729 merged 1 commit into
mainfrom
feat/issue-34
Mar 2, 2026
Merged

feat: add renderLatexPDF subprocess renderer#40
rohitm-1729 merged 1 commit into
mainfrom
feat/issue-34

Conversation

@rohitm-1729

Copy link
Copy Markdown
Owner

Summary

  • Adds src/lib/pdf/render-latex-pdf.ts exporting renderLatexPDF(tex: string): Promise<{ buffer: Buffer; pages: number }>
  • Uses execFile (not exec) for security — avoids shell injection
  • Writes LaTeX source to a temp directory, runs pdflatex -interaction=nonstopmode, reads the output PDF, then cleans up the temp dir in a finally block
  • Page count is derived from /Type /Page markers in the raw PDF binary; defaults to 1 if none found

Test plan

  • Unit tests cover happy path (buffer returned, page count returned)
  • Verifies pdflatex is called with -interaction=nonstopmode and -output-directory flags
  • Verifies temp directory is cleaned up even when pdflatex fails
  • Verifies temp directory is cleaned up even when readFile fails
  • Verifies multi-page detection and default-to-1 fallback
  • All 7 tests pass (npm test)

Closes #34

🤖 Generated with Claude Code

Implements src/lib/pdf/render-latex-pdf.ts as specified in issue #34.
Uses execFile (not exec) for security, writes .tex to a mkdtemp
scratch directory, invokes pdflatex with -interaction=nonstopmode,
reads the resulting PDF, and cleans up the temp dir in a finally block.
Page count is derived from the same /Type /Page regex used in step5.

Closes #34

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@rohitm-1729
rohitm-1729 merged commit 8f52db1 into main Mar 2, 2026
2 checks passed
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.

feat: pdflatex render subprocess (render-latex-pdf.ts)

1 participant