mirror of
https://github.com/Dadido3/go-typst.git
synced 2025-04-11 12:13:16 +00:00
Add PDFStandard type and constants
Also rename the PDFStandard field in CLIOptions to PDFStandards, and change its type from string to []PDFStandard. This is a breaking change.
This commit is contained in:
parent
c2d62b2373
commit
0668d15070
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2024 David Vogel
|
// Copyright (c) 2024-2025 David Vogel
|
||||||
//
|
//
|
||||||
// This software is released under the MIT License.
|
// This software is released under the MIT License.
|
||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
@ -22,6 +22,14 @@ const (
|
|||||||
OutputFormatHTML OutputFormat = "html" // this format is only available since 0.13.0
|
OutputFormatHTML OutputFormat = "html" // this format is only available since 0.13.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type PDFStandard string
|
||||||
|
|
||||||
|
const (
|
||||||
|
PDFStandard1_7 PDFStandard = "1.7" // PDF 1.7
|
||||||
|
PDFStandardA_2B PDFStandard = "a-2b" // PDF/A-2b
|
||||||
|
PDFStandardA_3B PDFStandard = "a-3b" // PDF/A-3b (Available since Typst 0.13.0 and later)
|
||||||
|
)
|
||||||
|
|
||||||
type CLIOptions struct {
|
type CLIOptions struct {
|
||||||
Root string // Configures the project root (for absolute paths).
|
Root string // Configures the project root (for absolute paths).
|
||||||
Input map[string]string // String key-value pairs visible through `sys.inputs`.
|
Input map[string]string // String key-value pairs visible through `sys.inputs`.
|
||||||
@ -42,13 +50,10 @@ type CLIOptions struct {
|
|||||||
Format OutputFormat // The format of the output file, inferred from the extension by default.
|
Format OutputFormat // The format of the output file, inferred from the extension by default.
|
||||||
PPI int // The PPI (pixels per inch) to use for PNG export. Defaults to 144.
|
PPI int // The PPI (pixels per inch) to use for PNG export. Defaults to 144.
|
||||||
|
|
||||||
// One (or multiple comma-separated) PDF standards that Typst will enforce conformance with.
|
// One (or multiple) PDF standards that Typst will enforce conformance with.
|
||||||
//
|
//
|
||||||
// Possible values:
|
// See typst.PDFStandard for possible values.
|
||||||
//
|
PDFStandards []PDFStandard
|
||||||
// - 1.7: PDF 1.7
|
|
||||||
// - a-2b: PDF/A-2b
|
|
||||||
PDFStandard string
|
|
||||||
|
|
||||||
Custom []string // Custom command line options go here.
|
Custom []string // Custom command line options go here.
|
||||||
}
|
}
|
||||||
@ -112,8 +117,15 @@ func (c *CLIOptions) Args() (result []string) {
|
|||||||
result = append(result, "--ppi", strconv.FormatInt(int64(c.PPI), 10))
|
result = append(result, "--ppi", strconv.FormatInt(int64(c.PPI), 10))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.PDFStandard != "" {
|
if len(c.PDFStandards) > 0 {
|
||||||
result = append(result, "--pdf-standard", c.PDFStandard)
|
var standards string
|
||||||
|
for i, standard := range c.PDFStandards {
|
||||||
|
if i > 0 {
|
||||||
|
standards += ","
|
||||||
|
}
|
||||||
|
standards += string(standard)
|
||||||
|
}
|
||||||
|
result = append(result, "--pdf-standard", standards)
|
||||||
}
|
}
|
||||||
|
|
||||||
result = append(result, c.Custom...)
|
result = append(result, c.Custom...)
|
||||||
|
Loading…
Reference in New Issue
Block a user