Skip to content

Typst - #1063

Merged
mikebarkmin merged 5 commits into
mainfrom
typst
Jan 7, 2026
Merged

Typst#1063
mikebarkmin merged 5 commits into
mainfrom
typst

Conversation

@mikebarkmin

Copy link
Copy Markdown
Member

No description provided.

@vercel

vercelBot commented Jan 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentReviewUpdated (UTC)
hyperbook-4fwaReadyReadyPreview, CommentJan 7, 2026 10:37pm

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a comprehensive Typst directive to Hyperbook, enabling users to write and preview Typst documents directly within their documentation. The implementation includes an interactive editor with syntax highlighting, multi-file project support, binary file handling (images, fonts), PDF export, and project ZIP download functionality.

Key changes:

  • New Typst directive with both preview and edit modes supporting live rendering
  • Multi-file project support with tabbed interface for managing source files
  • Binary file upload and management for assets like images
  • Error handling with dismissible overlays that preserve the last successful render

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 37 comments.

Show a summary per file
FileDescription
website/en/book/elements/typst.mdEnglish documentation for the new Typst directive with usage examples
website/de/book/elements/typst.mdGerman translation of the Typst documentation
website/en/book/changelog.mdChangelog entry for v0.73.0 describing the new feature
website/en/book/elements/typst-doc.typExample Typst source file for demonstration
website/de/book/elements/typst-doc.typExample Typst source file for German documentation
packages/markdown/src/remarkDirectiveTypst.tsCore directive implementation parsing Typst blocks and generating HTML
packages/markdown/src/rehypeHtmlStructure.tsAdds Prism Typst syntax highlighter script to HTML head
packages/markdown/src/process.tsIntegrates the Typst directive into the markdown processing pipeline
packages/markdown/assets/directive-typst/client.jsClient-side JavaScript for Typst rendering, file management, and exports
packages/markdown/assets/directive-typst/style.cssStyling for the Typst editor and preview interface
packages/markdown/assets/prism/prism-typst.jsPrism syntax highlighting grammar for Typst language
packages/markdown/assets/uzip/uzip.jsZIP library for project downloads (third-party library)
packages/markdown/assets/store.jsDatabase schema update adding typst table for state persistence
packages/markdown/locales/en.jsonEnglish UI strings for Typst features
packages/markdown/locales/de.jsonGerman UI strings for Typst features
packages/markdown/tests/snapshots/process.test.ts.snapUpdated snapshots including Prism Typst script and 2026 copyright
.changeset/add-typst-directive.mdChangeset documenting the minor version bump

script.onerror = reject;
document.head.appendChild(script);
});

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

Missing error handling: The loadTypst() function is called without proper error handling. If the script fails to load or typst initialization fails, the promise rejection is not properly caught in the calling context, which could lead to unhandled promise rejections.

Suggested change
// Attach a catch handler to avoid unhandled promise rejections
typstLoadPromise.catch((error)=>{
console.error("Failed to load Typst:",error);
});

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,307 @@
---
name: Typst
permaid: typst

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

The frontmatter field 'permaid' appears to be a typo. It should likely be 'permalink' or 'permaid' might be an intentional custom field name. If it's a typo, it should be corrected. If it's intentional, this comment can be disregarded.

Suggested change
permaid: typst
permalink: typst

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,307 @@
---
name: Typst
permaid: typst

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

The frontmatter field 'permaid' appears to be a typo. It should likely be 'permalink' or 'permaid' might be an intentional custom field name. If it's a typo, it should be corrected. If it's intentional, this comment can be disregarded.

Suggested change
permaid: typst
permalink: typst

Copilot uses AI. Check for mistakes.

#figure(
image("/hello.jpg", width: 80%),
caption: "A complex figure with an image and a table caption."

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

Inconsistency in captions: line 292 says "A complex figure with an image and a table caption" but line 260 and 304 use different wording. The caption should accurately describe the content. If there's no table in the figure, "table caption" is misleading.

Copilot uses AI. Check for mistakes.
Comment on lines +176 to +195
errorOverlay.innerHTML = `
<div class="typst-error-content">
<div class="typst-error-header">
<span class="typst-error-title">⚠️ Typst Error</span>
<button class="typst-error-close" title="Dismiss error">×</button>
</div>
<div class="typst-error-message">${errorText}</div>
</div>
`;

// Add close button functionality
const closeBtn = errorOverlay.querySelector('.typst-error-close');
closeBtn.addEventListener('click', () => {
errorOverlay.remove();
});

previewContainer.appendChild(errorOverlay);
} else {
// Fallback: show error in preview container directly
container.innerHTML = `<div class="typst-error">${errorText}</div>`;

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

Security concern: Using innerHTML with user-generated content (errorText) could lead to XSS vulnerabilities. The error text should be sanitized or set using textContent instead of innerHTML to prevent potential script injection.

Suggested change
errorOverlay.innerHTML= `
<divclass="typst-error-content">
<divclass="typst-error-header">
<spanclass="typst-error-title">⚠️ Typst Error</span>
<buttonclass="typst-error-close"title="Dismiss error">×</button>
</div>
<divclass="typst-error-message">${errorText}</div>
</div>
`;
// Add close button functionality
constcloseBtn=errorOverlay.querySelector('.typst-error-close');
closeBtn.addEventListener('click',()=>{
errorOverlay.remove();
});
previewContainer.appendChild(errorOverlay);
}else{
// Fallback: show error in preview container directly
container.innerHTML=`<div class="typst-error">${errorText}</div>`;
// Static HTML structure; dynamic error text is set safely via textContent
errorOverlay.innerHTML= `
<divclass="typst-error-content">
<divclass="typst-error-header">
<spanclass="typst-error-title">⚠️ Typst Error</span>
<buttonclass="typst-error-close"title="Dismiss error">×</button>
</div>
<divclass="typst-error-message"></div>
</div>
`;
// Set error message text safely
constmessageEl=errorOverlay.querySelector('.typst-error-message');
if(messageEl){
messageEl.textContent=errorText;
}
// Add close button functionality
constcloseBtn=errorOverlay.querySelector('.typst-error-close');
if(closeBtn){
closeBtn.addEventListener('click',()=>{
errorOverlay.remove();
});
}
previewContainer.appendChild(errorOverlay);
}else{
// Fallback: show error in preview container directly
// Clear previous content and insert error text safely
container.innerHTML='';
consterrorDiv=document.createElement('div');
errorDiv.className='typst-error';
errorDiv.textContent=errorText;
container.appendChild(errorDiv);

Copilot uses AI. Check for mistakes.
Comment on lines +982 to +983
lc = 0;
li = lc = ebits = 0;

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

The value assigned to lc here is unused.

Suggested change
lc=0;
li=lc=ebits=0;
li=ebits=0;

Copilot uses AI. Check for mistakes.
pos = _writeBlock(1, lits, li, ebits, data, bs, i - bs, out, pos);
li = 0;
lc = 0;
li = lc = ebits = 0;

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

The value assigned to ebits here is unused.

Suggested change
li=lc=ebits=0;
li=lc=0;

Copilot uses AI. Check for mistakes.
li = 0;
lc = 0;
li = lc = ebits = 0;
bs = i;

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

The value assigned to bs here is unused.

Suggested change
bs = i;

Copilot uses AI. Check for mistakes.
greedy: true,
},
url: {
pattern: /https?\:\/\/[\w.\/\-@:%._\+~#=]*[\w\/]/,

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

Character '.' is repeated in the same character class.

Suggested change
pattern: /https?\:\/\/[\w.\/\-@:%._\+~#=]*[\w\/]/,
pattern: /https?\:\/\/[\w\/\-@:%._\+~#=]*[\w\/]/,

Copilot uses AI. Check for mistakes.
pos = _writeLit(l, tree, out, pos);
var rsl = l == 16 ? 2 : l == 17 ? 3 : 7;
if (l > 15) {
_putsE(out, pos, rst, rsl);

CopilotAIJan 7, 2026

Copy link

Choose a reason for hiding this comment

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

Superfluous argument passed to function _putsE.

Copilot uses AI. Check for mistakes.
@mikebarkmin
mikebarkmin merged commit 66a7234 into mainJan 7, 2026
9 checks passed
@mikebarkmin
mikebarkmin deleted the typst branch January 7, 2026 22:45
@github-actionsgithub-actionsBot mentioned this pull request Jan 7, 2026
Sign up for freeto 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

@mikebarkmin