refactor(compiler): resolve output before args

Problem: presets that need the output path in their args function
(markdown, github) had to recompute it inline, duplicating the same
gsub expression already in the output field.

Solution: resolve output_file first in M.compile, then extend ctx with
output = output_file into a resolved_ctx before evaluating args and cwd.
Presets can now reference ctx.output directly. Add output? to the
preview.Context type annotation.
This commit is contained in:
Barrett Ruth 2026-03-03 15:10:06 -05:00
parent 4c22f84b31
commit af8bb49122
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
4 changed files with 14 additions and 11 deletions

View file

@ -150,6 +150,7 @@ describe('presets', function()
file = '/tmp/document.md',
root = '/tmp',
ft = 'markdown',
output = '/tmp/document.html',
}
it('has ft', function()
@ -233,6 +234,7 @@ describe('presets', function()
file = '/tmp/document.md',
root = '/tmp',
ft = 'markdown',
output = '/tmp/document.html',
}
it('has ft', function()