Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📤 Refactor exports for more flexibility #1033

Merged
merged 12 commits into from
Mar 28, 2024
Merged

📤 Refactor exports for more flexibility #1033

merged 12 commits into from
Mar 28, 2024

Conversation

fwkoch
Copy link
Collaborator

@fwkoch fwkoch commented Mar 26, 2024

Previously, when defining exports, you had to specify format:

---
exports:
  - format: pdf
---

This is redundant with extensions...

---
exports:
  - format: pdf
    output: index.pdf
---

...and templates...

---
exports:
  - format: typst
    output: lapreprint-typst
---

There is also ambiguity around what format: pdf means, e.g. if I want a pdf built with typst, this failed since pdf was synonymous with tex build:

---
exports:
  - format: pdf
    output: lapreprint-typst
---

This PR refactors the export collection logic to be more human-friendly.

  • Format can now be determined from format, output, or template, redundancy is not required
  • format: pdf is more flexible and can result in a typst build if typst template or file extension are used
  • Export may now specify zip: true - previously the only way to zip outputs was provide an output with .zip extension.

It also centralizes the logic into format-agnostic functions, so the collectTexExportOptions, collectDocxExportOptions, etc functions are deprecated. Also previously there was some conflation between CLI-provided export options and file-provided export options... this has been separated a bit more cleanly, so all the CLI-provided options are handled in build, not in collectExportOptions...

👀 ALSO 👀 (Definitely not too much here. Definitely not.) This addresses #1021 by throwing an error when typst executable is not available, rather than silently carrying on and encountering other inexplicable errors...

* If `format` or `output` give PDF export, we look at the template kind and switch to `typst`
* in the case of a typst template.
*/
function resolveFormat(vfile: VFile, exp: Export): ExportFormats | undefined {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to add some unit tests at least on these resolve* functions before merging this...

@rowanc1 rowanc1 merged commit bba5baf into main Mar 28, 2024
4 checks passed
@rowanc1 rowanc1 deleted the feat/export-refactor branch March 28, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants