Skip to content

Commit

Permalink
Typst css would mess with text tag in graphviz svg
Browse files Browse the repository at this point in the history
  • Loading branch information
utensil committed Sep 25, 2024
1 parent c4ece27 commit 506fc8f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
16 changes: 12 additions & 4 deletions bun/typst.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,30 @@ const fetch_text = async (url) => {

const typst_tags = document.querySelectorAll('.typst-root.loading')
// console.log(typst_tags);
for (let i = 0; i < typst_tags.length; i++) {
const typst_tag = typst_tags[i]
for (const typst_tag of typst_tags) {
let typst_src_url = typst_tag.getAttribute('data-src')

try {
if (typst_src_url) {
if (!typst_src_url.startsWith('/')) {
typst_src_url = `/${typst_src_url}`
}
const rendered = await $typst.svg({ mainFilePath: typst_src_url })
const rendered = await $typst.svg({
mainFilePath: typst_src_url, data_selection: {
js: true, css: false, defs: true, body: true
}
})
typst_tag.innerHTML = rendered
typst_tag.classList.remove('loading')
} else {
const typst_source = typst_tag.textContent
// console.log(typst_source);
const rendered = await $typst.svg({ mainContent: typst_source })
const rendered = await $typst.svg({
mainContent: typst_source,
data_selection: {
js: true, css: false, defs: true, body: true
}
})
typst_tag.innerHTML = rendered
typst_tag.classList.remove('loading')
}
Expand Down
4 changes: 4 additions & 0 deletions bun/uts-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ code.highlight.grace-loading {
min-width: 70ex;
}

.typst-root svg .tsel {
visibility: hidden;
}

.optional {
color: var(--uts-text-gentle);
}
Expand Down
24 changes: 24 additions & 0 deletions trees/uts-001M.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
\import{macros}
% clifford hopf spin tt ag math draft tech exp notes
\tag{draft}

\note{test graphviz transcludes}{

% \transclude{uts-0003}
% \transclude{uts-000E}
% \transclude{uts-000M}
% \transclude{uts-000Q}
\transclude{uts-000R}
% \transclude{uts-000W}
% \transclude{uts-000Y}
% \transclude{uts-0015}
% \transclude{uts-001C}
% \transclude{uts-001D}
% \transclude{uts-001E}
% \transclude{uts-001F}
% \transclude{uts-001H}
% \transclude{uts-001I}
% \transclude{uts-001J}

\transclude{uts-001L}
}

0 comments on commit 506fc8f

Please sign in to comment.