-
-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
bugSomething isn't working correctlySomething isn't working correctly
Description
Describe the bug
I was rendering markdown to html and then displaying that with
core.NewText(b).SetText(buf.String())
I noticed that images included as html don't display on either desktop or web views - yet, oddly, they are displayed in the static preview before the wasm loads.
Will displaying images included as html be supported?
Is there any suggested workaround for this, currently?
How to reproduce
One may run a modified version of the example code to reproduce this. Simply omit the parts of the code which refer to embedded files.
Run core run web to view the web version. Observe that in the static preview,, the image is visible, but when the wasm loads, the image isn't there.
Example code
package main
import (
"bytes"
"log"
"embed"
"regexp"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/renderer/html"
"github.com/0magnet/calvin"
"cogentcore.org/core/base/mergefs"
"cogentcore.org/core/core"
"cogentcore.org/core/paint"
"cogentcore.org/core/styles"
"github.com/skycoin/skywire"
)
//go:embed mononoki/*.ttf
var mononoki embed.FS
func main() {
core.TheApp.SetSceneInit(func(sc *core.Scene) {
sc.SetWidgetInit(func(w core.Widget) {
w.AsWidget().Styler(func(s *styles.Style) {
s.Font.Family = "mononoki"
s.Text.LineHeight.Em(1)
s.Text.WhiteSpace = styles.WhiteSpacePreWrap
})
})
})
b := core.NewBody()
paint.FontLibrary.FontsFS = mergefs.Merge(paint.FontLibrary.FontsFS, mononoki)
paint.FontLibrary.UpdateFontsAvail()
core.NewText(b).SetText(calvin.AsciiFont("skywire rewards"))
// Preprocess to replace ~text~ with ~~text~~ for strikethrough
re := regexp.MustCompile(`~(.*?)~`)
rules := re.ReplaceAllString(skywire.MainnetRules, "~~$1~~")
var buf bytes.Buffer
md := goldmark.New(
goldmark.WithExtensions(extension.Strikethrough),
goldmark.WithRendererOptions(html.WithXHTML()), // Optional: add XHTML compatibility
)
if err := md.Convert([]byte(rules), &buf); err != nil {
log.Fatal("Error rendering markdown as HTML:", err)
}
core.NewText(b).SetText(buf.String())
b.RunMainWindow()
}Relevant output
Platform
Web
Metadata
Metadata
Assignees
Labels
bugSomething isn't working correctlySomething isn't working correctly
Type
Projects
Status
Done