Support for using font not system installed - #22
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds a Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/rst2typst/pdf.py (1)
50-51: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winIgnore empty environment variable values.
If
TYPST_FONT_PATHSis defined but empty (e.g.,TYPST_FONT_PATHS=""),split(os.pathsep)will return[""], passing an empty string as a font path to Typst. Usingos.environ.get(...)prevents this.♻️ Proposed refactor
- if "TYPST_FONT_PATHS" in os.environ: - font_paths += os.environ["TYPST_FONT_PATHS"].split(os.pathsep) + if env_paths := os.environ.get("TYPST_FONT_PATHS"): + font_paths += env_paths.split(os.pathsep)(Note: If you need to support Python 3.7 or earlier where the walrus operator is not available, you can assign it first and then check if it's truthy).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/rst2typst/pdf.py` around lines 50 - 51, Update the TYPST_FONT_PATHS handling to retrieve the environment value and only split and append its entries when the value is non-empty, ensuring an empty variable does not add an empty font path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/cli.rst`:
- Around line 77-85: Refine the prose in the --font-paths documentation for
grammatical correctness and readability, including the description of custom
font directories and the explanation of when to provide a folder path. Preserve
the option name, type, default value, and intended behavior.
In `@src/rst2typst/pdf.py`:
- Around line 29-37: Update the --font-paths argument definition to parse
multiple paths as a list instead of storing one raw string, using the existing
downstream font_paths handling with an append action or equivalent
comma-separated-list validation. Preserve the default empty-list behavior.
---
Nitpick comments:
In `@src/rst2typst/pdf.py`:
- Around line 50-51: Update the TYPST_FONT_PATHS handling to retrieve the
environment value and only split and append its entries when the value is
non-empty, ensuring an empty variable does not add an empty font path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a8f98dc1-c301-4e7d-9641-132315b2e050
📒 Files selected for processing (3)
docs/cli.rstsrc/rst2typst/pdf.pytests/test_pdf.py
c595a29 to
7a0e867
Compare
For #20
Summary by CodeRabbit
New Features
--font-pathsoption to specify directories containing custom fonts when generating PDFs.TYPST_FONT_PATHSenvironment variable.Documentation
Tests