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

Add support for missing references (w/ warnings) #4035

Open
m-krastev opened this issue Apr 29, 2024 · 6 comments
Open

Add support for missing references (w/ warnings) #4035

m-krastev opened this issue Apr 29, 2024 · 6 comments
Labels
diagnostics Improvements to compiler errors feature request New feature or request

Comments

@m-krastev
Copy link

Description

Coming from LaTeX, you could compile a document even if a reference is not defined. This would trigger a warning and a "??" would be printed on the resulting file.

Currently, Typst just errs and exits the whole compiler process (e.g. if using typst watch).

Use Case

A similar functionality where the error is ignored and a warning is emitted instead would help creative flow while writing so that one does not have to immediately go back to a missing reference and try to address it.

@m-krastev m-krastev added the feature request New feature or request label Apr 29, 2024
@laurmaedje laurmaedje added the diagnostics Improvements to compiler errors label Apr 29, 2024
@Enivex
Copy link
Collaborator

Enivex commented Apr 29, 2024

See #1276 and #1322

@m-krastev
Copy link
Author

I would love for the functionality of #1276 to be included in the base compiler, as this should not be considered as a critical compiler failure.

@laurmaedje
Copy link
Member

If we can come up with a good design, I'm open to it.

@Coekjan
Copy link
Contributor

Coekjan commented May 8, 2024

Maybe we can add a cli argument (like --allow-missing-ref, or something else) to toggle the compile/watch behavior:

  1. normal (current) behavior: deny missing ref
  2. --allow-missing-ref behavior: warn on missing ref, and print ? (or something else, or something configurable by cli args) in the result

@LaurenzV
Copy link
Sponsor Collaborator

LaurenzV commented May 8, 2024

I think instead of having a specific flags just for refs we should instead think about how to implement a more generalized system for enabling/disabling warnings, then this could be extended to this specific use case as well.

@geajack
Copy link

geajack commented May 16, 2024

Yes! You want to be able to just put the references in as you're writing and add the actual reference targets at the end. An --ignore-refs flag or something would be ideal. The current behavior encourages putting in a bunch of dummy referands just to get the compiler off your back, which is worse since you might forget them.

This at the beginning of the document makes a good workaround:

#show ref: it => {
  it.target
}

However, this doesn't solve the problem because now all refs will be replaced by a placeholder, even ones that work, so you can't gradually fix broken refs and have them fill in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostics Improvements to compiler errors feature request New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants