Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Exlude (Empty) Files from PDF Export #285

Closed
2 tasks done
kothavade opened this issue Sep 7, 2023 · 7 comments · Fixed by #389
Closed
2 tasks done

Exlude (Empty) Files from PDF Export #285

kothavade opened this issue Sep 7, 2023 · 7 comments · Fixed by #389

Comments

@kothavade
Copy link

kothavade commented Sep 7, 2023

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the discussions and believe that my question is not already covered.

Feature Request

Hi, I find that keeping "typst-lsp.exportPdf" set often ends up generating blank pdf exports for files that are not meant to be compiled, such as templates or utility files. Having to manually delete these blank files gets tedious, so I'd like a settings interface to exclude files from the pdf export.

I imagine something along the lines of "typst-lsp.exportPdfExclude": "glob string" or even

"typst-lsp.exportPdfExclude": [
    "template.typ",
    "util.typ"
]

Alternatively, a setting for detecting empty files and not generating them would be even more helpful for my own use-case, but is less general, and I'm not sure what the complexity of implementing this would be.

Thanks for the project, it's been working wonderfully for me so far!

@platformer
Copy link

An include-list might be more useful since you'd be explicitly listing the files you care about, and you can add any number of helper files without having to change the vscode config. Though I agree, automatically excluding blank PDFs would be the most user-friendly option.

@Enter-tainer
Copy link
Collaborator

Enter-tainer commented Sep 8, 2023

currently there is no good way for lsp to determine which file is the entry point. This may also happen in c/c++ and they use a compile_commands.json to determine where the entrypoint is.

i'd suggest something like a typst-project.toml or package.json to determine where the entrypoint is.

include/exclude list is obviously suboptimal but it's like a quick workaround.

Perhaps maintain a "import count" for files in project and only consider import count == 0 ones as entrypoint

@kothavade
Copy link
Author

kothavade commented Sep 8, 2023

While I agree that a typst project config file of some sorts makes the most sense, I feel like that is a pretty large change that would require a lot of community input, and should probably be standardized in conjunction with the @typst project.

IMO a whitelist glob (I agree w/ @platformer, this seems better than an exclude list) in the LSP config would be a great solution for the time being, and if/when a project format is decided on, the setting can be deprecated.

@Myriad-Dreamin
Copy link
Collaborator

A very simple approach is to detect your document's title and don't export that documents with empty title.

// main.typ, this document will have pdf exported
set document(title: "...")
// package.typ, this document won't have pdf exported
// set document(title: "")

@Marmare314
Copy link

Related issue with a different solution: #11.

@nikhilweee
Copy link

@Marmare314 Are you referring to on-demand compile? I feel that's a workaround at best, not a solution.

@nikhilweee
Copy link

Typst packages already use a typst.toml which also has an excludes section, is there a way we could leverage that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants