diff --git a/cli.go b/cli.go index 57d1442..75c7ad2 100644 --- a/cli.go +++ b/cli.go @@ -15,12 +15,12 @@ import ( // TODO: Add docker support to CLI, by calling docker run instead type CLI struct { - ExecutablePath string // The typst executable path can be overridden here. Otherwise the default path will be used. + ExecutablePath string // The Typst executable path can be overridden here. Otherwise the default path will be used. } -// TODO: Add method for querying the typst version resulting in a semver object +// TODO: Add method for querying the Typst version resulting in a semver object -// VersionString returns the version string as returned by typst. +// VersionString returns the version string as returned by Typst. func (c CLI) VersionString() (string, error) { // Get path of executable. execPath := ExecutablePath @@ -46,7 +46,7 @@ func (c CLI) VersionString() (string, error) { return output.String(), nil } -// Compile takes a typst document from input, and renders it into the output writer. +// 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 *CLIOptions) error { args := []string{"c"} @@ -80,10 +80,10 @@ func (c CLI) Compile(input io.Reader, output io.Writer, options *CLIOptions) err return nil } -// CompileWithVariables takes a typst document from input, and renders it into the output writer. +// CompileWithVariables takes a Typst document from input, and renders it into the output writer. // The options parameter is optional. // -// Additionally this will inject the given map of variables into the global scope of the typst document. +// Additionally this will inject the given map of variables into the global scope of the Typst document. // // Deprecated: You should use InjectValues in combination with the normal Compile method instead. func (c CLI) CompileWithVariables(input io.Reader, output io.Writer, options *CLIOptions, variables map[string]any) error { diff --git a/cli_unix.go b/cli_unix.go index 46c763a..c200797 100644 --- a/cli_unix.go +++ b/cli_unix.go @@ -1,4 +1,4 @@ -// Copyright (c) 2024 David Vogel +// Copyright (c) 2024-2025 David Vogel // // This software is released under the MIT License. // https://opensource.org/licenses/MIT @@ -7,5 +7,5 @@ package typst -// The path to the typst executable. +// The path to the Typst executable. var ExecutablePath = "typst" diff --git a/cli_windows.go b/cli_windows.go index 20b38de..ecfeed5 100644 --- a/cli_windows.go +++ b/cli_windows.go @@ -1,4 +1,4 @@ -// Copyright (c) 2024 David Vogel +// Copyright (c) 2024-2025 David Vogel // // This software is released under the MIT License. // https://opensource.org/licenses/MIT @@ -7,9 +7,9 @@ package typst -// The path to the typst executable. +// The path to the Typst executable. // We assume the executable is in the current working directory. //var ExecutablePath = "." + string(filepath.Separator) + filepath.Join("typst.exe") -// The path to the typst executable. +// The path to the Typst executable. var ExecutablePath = "typst.exe" diff --git a/errors.go b/errors.go index 5b7f89b..3440692 100644 --- a/errors.go +++ b/errors.go @@ -14,13 +14,13 @@ import ( // ErrorDetails contains the details of a typst.Error. type ErrorDetails struct { Message string // The parsed error message. - Path string // Path of the typst file where the error is located in. Zero value means that there is no further information. + Path string // Path of the Typst file where the error is located in. Zero value means that there is no further information. Line int // Line number of the error. Zero value means that there is no further information. Column int // Column of the error. Zero value means that there is no further information. } -// Error represents a typst error. -// This can contain multiple sub-errors or sub-warnings. +// Error represents an error as returned by Typst. +// This can contain multiple sub-errors or sub-warnings which are listed in the field Details. type Error struct { Inner error diff --git a/identifier.go b/identifier.go index ff76c3b..b73c74f 100644 --- a/identifier.go +++ b/identifier.go @@ -1,4 +1,4 @@ -// Copyright (c) 2024 David Vogel +// Copyright (c) 2024-2025 David Vogel // // This software is released under the MIT License. // https://opensource.org/licenses/MIT @@ -11,7 +11,7 @@ import ( "github.com/smasher164/xid" ) -// CleanIdentifier will return the input cleaned up in a way so that it can safely be used as a typst identifier. +// CleanIdentifier will return the input cleaned up in a way so that it can safely be used as a Typst identifier. // This function will replace all illegal characters, which means collisions are possible in some cases. // // See https://github.com/typst/typst/blob/76c24ee6e35715cd14bb892d7b6b8d775c680bf7/crates/typst-syntax/src/lexer.rs#L932 for details. diff --git a/image.go b/image.go index c17ef1a..4d0263c 100644 --- a/image.go +++ b/image.go @@ -13,7 +13,7 @@ import ( "strconv" ) -// Image can be used to encode any image.Image into a typst image. +// Image can be used to encode any image.Image into a Typst image. // // For this, just wrap any image.Image with this type before passing it to MarshalValue or a ValueEncoder. type Image struct{ image.Image } diff --git a/util.go b/util.go index 625e776..c0e9ac0 100644 --- a/util.go +++ b/util.go @@ -13,7 +13,7 @@ import ( ) // InjectValues will write the given key-value pairs as Typst markup into output. -// This can be used to inject Go values into typst documents. +// This can be used to inject Go values into Typst documents. // // Every key in values needs to be a valid identifier, otherwise this function will return an error. // Every value in values will be marshaled according to ValueEncoder into equivalent Typst markup. diff --git a/value-encoder.go b/value-encoder.go index 8911edb..b56a056 100644 --- a/value-encoder.go +++ b/value-encoder.go @@ -18,7 +18,7 @@ import ( "time" ) -// MarshalValue takes any go type and returns a typst markup representation as a byte slice. +// MarshalValue takes any Go type and returns a Typst markup representation as a byte slice. func MarshalValue(v any) ([]byte, error) { var buf bytes.Buffer @@ -372,7 +372,7 @@ func (e *ValueEncoder) EncodeByteSlice(bb []byte) error { return err } - // TODO: Encode byte slice via base64 or similar and use a typst package to convert it into the corresponding bytes type + // TODO: Encode byte slice via base64 or similar and use a Typst package to convert it into the corresponding bytes type for i, b := range bb { if i > 0 { diff --git a/value-encoder_test.go b/value-encoder_test.go index 530966a..c80cc11 100644 --- a/value-encoder_test.go +++ b/value-encoder_test.go @@ -184,7 +184,7 @@ func TestValueEncoder(t *testing.T) { err := vEnc.Encode(tt.params) switch { case err != nil && !tt.wantErr: - t.Fatalf("Failed to encode typst values: %v", err) + t.Fatalf("Failed to encode Typst values: %v", err) case err == nil && tt.wantErr: t.Fatalf("Expected error, but got none") } @@ -199,7 +199,7 @@ func TestValueEncoder(t *testing.T) { input := strings.NewReader("#" + result.String()) var output bytes.Buffer if err := typstCLI.Compile(input, &output, nil); err != nil { - t.Errorf("Failed to compile generated typst markup: %v", err) + t.Errorf("Failed to compile generated Typst markup: %v", err) } } })