diff --git a/caller.go b/caller.go index e23ea5b..b70955b 100644 --- a/caller.go +++ b/caller.go @@ -21,5 +21,5 @@ type Caller interface { // Compile takes a Typst document from the supplied input reader, and renders it into the output writer. // The options parameter is optional, and can be nil. - Compile(input io.Reader, output io.Writer, options *Options) error + Compile(input io.Reader, output io.Writer, options *OptionsCompile) error } diff --git a/cli-options.go b/cli-options.go index d45f3fd..6d05ccc 100644 --- a/cli-options.go +++ b/cli-options.go @@ -7,5 +7,5 @@ package typst // CLIOptions contains all parameters that can be passed to a Typst CLI. // -// Deprecated: Use typst.Options instead. -type CLIOptions = Options +// Deprecated: Use typst.OptionsCompile instead. +type CLIOptions = OptionsCompile diff --git a/cli.go b/cli.go index 6afbee2..0c7d629 100644 --- a/cli.go +++ b/cli.go @@ -89,13 +89,13 @@ func (c CLI) Fonts() ([]string, error) { } // Compile takes a Typst document from input, and renders it into the output writer. -// The options parameter is optional. -func (c CLI) Compile(input io.Reader, output io.Writer, options *Options) error { +// The options parameter is optional, and can be nil. +func (c CLI) Compile(input io.Reader, output io.Writer, options *OptionsCompile) error { args := []string{"c"} if options != nil { args = append(args, options.Args()...) } - args = append(args, "--diagnostic-format", "human", "-", "-") // TODO: Move these default arguments into Options + args = append(args, "--diagnostic-format", "human", "-", "-") // TODO: Move these default arguments into OptionsCompile // Get path of executable. execPath := ExecutablePath @@ -127,12 +127,12 @@ func (c CLI) Compile(input io.Reader, output io.Writer, options *Options) error } // CompileWithVariables takes a Typst document from input, and renders it into the output writer. -// The options parameter is optional. +// The options parameter is optional, and can be nil. // // Additionally this will inject the given map of variables into the global scope of the Typst document. // // Deprecated: You should use typst.InjectValues in combination with the normal Compile method instead. -func (c CLI) CompileWithVariables(input io.Reader, output io.Writer, options *Options, variables map[string]any) error { +func (c CLI) CompileWithVariables(input io.Reader, output io.Writer, options *OptionsCompile, variables map[string]any) error { varBuffer := bytes.Buffer{} if err := InjectValues(&varBuffer, variables); err != nil { diff --git a/cli_test.go b/cli_test.go index 76e23b0..4f51566 100644 --- a/cli_test.go +++ b/cli_test.go @@ -49,7 +49,7 @@ func TestCLI_Compile(t *testing.T) { #lorem(5)`) - opts := typst.Options{ + opts := typst.OptionsCompile{ Format: typst.OutputFormatPNG, PPI: ppi, } diff --git a/docker.go b/docker.go index cc571eb..cb00930 100644 --- a/docker.go +++ b/docker.go @@ -95,8 +95,8 @@ func (d Docker) Fonts() ([]string, error) { } // Compile takes a Typst document from input, and renders it into the output writer. -// The options parameter is optional. -func (d Docker) Compile(input io.Reader, output io.Writer, options *Options) error { +// The options parameter is optional, and can be nil. +func (d Docker) Compile(input io.Reader, output io.Writer, options *OptionsCompile) error { image := DockerDefaultImage if d.Image != "" { image = d.Image diff --git a/docker_test.go b/docker_test.go index 10936ef..d3e9b58 100644 --- a/docker_test.go +++ b/docker_test.go @@ -48,7 +48,7 @@ func TestDocker_Compile(t *testing.T) { #lorem(5)`) - opts := typst.Options{ + opts := typst.OptionsCompile{ Format: typst.OutputFormatPNG, PPI: ppi, } @@ -84,7 +84,7 @@ func TestDocker_CompileWithWorkingDir(t *testing.T) { #show: doc => template()`) var w bytes.Buffer - err := typstCaller.Compile(r, &w, &typst.Options{Root: "/markup"}) + err := typstCaller.Compile(r, &w, &typst.OptionsCompile{Root: "/markup"}) if err != nil { t.Fatalf("Failed to compile document: %v.", err) } diff --git a/errors_test.go b/errors_test.go index b7c2855..35a8ce8 100644 --- a/errors_test.go +++ b/errors_test.go @@ -63,7 +63,7 @@ func TestErrors1(t *testing.T) { func TestErrors2(t *testing.T) { cli := typst.CLI{} - opts := typst.Options{ + opts := typst.OptionsCompile{ Pages: "a", } diff --git a/options.go b/options.go index 1c61930..e40fb05 100644 --- a/options.go +++ b/options.go @@ -45,8 +45,8 @@ const ( PDFStandardUA_1 PDFStandard = "ua-1" // PDF/UA-1 (Available since Typst 0.14.0) ) -// Options contains all parameters that can be passed to a Typst CLI. -type Options struct { +// OptionsCompile contains all parameters for the compile command. +type OptionsCompile struct { Root string // Configures the project root (for absolute paths). Input map[string]string // String key-value pairs visible through `sys.inputs`. FontPaths []string // Adds additional directories that are recursively searched for fonts. @@ -77,7 +77,7 @@ type Options struct { } // Args returns a list of CLI arguments that should be passed to the executable. -func (c *Options) Args() (result []string) { +func (c *OptionsCompile) Args() (result []string) { if c.Root != "" { result = append(result, "--root", c.Root) } diff --git a/options_test.go b/options_test.go index 4309833..9a93bd2 100644 --- a/options_test.go +++ b/options_test.go @@ -13,7 +13,7 @@ import ( ) func TestOptions(t *testing.T) { - o := typst.Options{ + o := typst.OptionsCompile{ FontPaths: []string{"somepath/to/somewhere", "another/to/somewhere"}, } args := o.Args()