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

TeX SSR #150

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
options
  • Loading branch information
Fil committed Nov 12, 2023
commit 2efbcf7164dc6161f8d023191b0bc3a38903c277
6 changes: 3 additions & 3 deletions src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ function getLiveSource(content, language, option): {source?: string; html?: stri
: language === "js"
? {source: content}
: language === "tex"
? maybeStaticTeX(content, true)
? maybeStaticTeX(content, {displayMode: true})
: language === "dot"
? {source: transpileTag(content, "dot", false)}
: language === "mermaid"
? {source: transpileTag(content, "await mermaid", false)}
: {};
}

function maybeStaticTeX(content, displayMode) {
function maybeStaticTeX(content, {displayMode = false} = {}) {
// We try SSR first. katex.renderToString errors when the expression contains
// some ${interpolation}, so this guarantees that interpolations will be
// handled in the browser. By way of consequence, TeX errors stemming from
Expand Down Expand Up @@ -281,7 +281,7 @@ function makePlaceholderRenderer(root: string, sourcePath: string): RenderRule {

// inline TeX?
if (token.content.startsWith("tex`") && token.content.endsWith("`")) {
const {html} = maybeStaticTeX(token.content.slice(4, -1), false);
const {html} = maybeStaticTeX(token.content.slice(4, -1));
if (html != null) return `<span id="cell-${id}">${html}</span>`;
}

Expand Down
Loading