Skip to content

Commit c4f76ad

Browse files
committed
fix(previewserver): Embed missing KaTeX fonts
- Add HTTP route to serve embedded KaTeX fonts - Update katex.min.css to reference only woff2 format fonts - Add KaTeX font files in woff2 format
1 parent f7945bb commit c4f76ad

22 files changed

Lines changed: 9 additions & 2 deletions

internal/previewserver/previewserver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package previewserver
22

33
import (
44
"context"
5-
_ "embed"
5+
"embed"
66
"encoding/json"
77
"fmt"
8+
"io/fs"
89
"math/rand"
910
"net/http"
1011
"net/url"
@@ -43,6 +44,8 @@ var (
4344
mermaid string
4445
//go:embed web/ws.js
4546
websocketJS string
47+
//go:embed web/fonts
48+
katexFontsFS embed.FS
4649

4750
broadcast = make(chan []byte)
4851
clients = make(map[*websocket.Conn]bool)
@@ -116,6 +119,10 @@ func (s *Server) Start() {
116119
http.HandleFunc("/mermaid.min.js", handleResponse("application/javascript", mermaid))
117120
http.HandleFunc("/ws.js", handleResponse("application/javascript", fmt.Sprintf(websocketJS, s.Port)))
118121

122+
// Serve embedded KaTeX fonts
123+
fontsSubFS, _ := fs.Sub(katexFontsFS, "web/fonts")
124+
http.Handle("/fonts/", http.StripPrefix("/fonts/", http.FileServer(http.FS(fontsSubFS))))
125+
119126
http.HandleFunc("/ws", handleWebSocket)
120127

121128
signal.Notify(stopChan, os.Interrupt)
27.4 KB
Binary file not shown.
6.75 KB
Binary file not shown.
6.75 KB
Binary file not shown.
11.1 KB
Binary file not shown.
11.1 KB
Binary file not shown.
24.7 KB
Binary file not shown.
16.4 KB
Binary file not shown.
16.6 KB
Binary file not shown.
25.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)