Skip to content

Commit

Permalink
fix(builder): support for [data-hl] and don't break variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Jun 8, 2024
1 parent fa58cb5 commit f6a981c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/build/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,11 @@ export async function html_builder() {
section.innerHTML = builder.querySelector("details")!.innerHTML
section.querySelector("summary")?.remove()
document.querySelector("main")!.append(section)
// Syntax highlighting
Array.from(document.querySelectorAll("[data-hl]")).forEach((_element) => {
const element = _element as unknown as HTMLElement
element.innerHTML = syntax.highlight(element.innerText, { language: element.getAttribute("data-hl")! }).value.trim()
element.removeAttribute("data-hl")
})
return `<!DOCTYPE html>${document.documentElement!.outerHTML}`
}
4 changes: 4 additions & 0 deletions app/mod.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ details summary a {
max-width: 4rem;
}

.matcha-build .variables td code:only-child {
white-space: nowrap;
}

.matcha-build .styling {
display: flex;
flex-wrap: wrap;
Expand Down

0 comments on commit f6a981c

Please sign in to comment.