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

🔧 Fix project cross-references in typst #1742

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/new-birds-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-typst': patch
---

Fix typst crossreferences to other pages
4 changes: 2 additions & 2 deletions packages/myst-to-typst/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,10 @@ const handlers: Record<string, Handler> = {
legend: captionHandler,
captionNumber: () => undefined,
crossReference(node: CrossReference, state, parent) {
if (node.remote) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

xrefs to other pages are still considered remote - we only want to do this if there is a remoteBaseUrl, i.e. they are xrefs to a totally separate project.

if (node.remoteBaseUrl) {
// We don't want to handle remote references, treat them as links
const url =
(node.remoteBaseUrl ?? '') +
node.remoteBaseUrl +
(node.url === '/' ? '' : node.url ?? '') +
(node.html_id ? `#${node.html_id}` : '');
linkHandler({ ...node, url: url }, state);
Expand Down
Loading