# goldmark

[github.com/yuin/goldmark](https://github.com/yuin/goldmark) · MIT

## For hotty.neuroplast.io

1 patch on `v1.8.6`. HOTTY's website is a terminal program that runs in the browser: Go, compiled to WebAssembly with TinyGo. It renders Markdown with goldmark, and goldmark v1 compiles regular expressions when its packages are initialized, which crashes a TinyGo WebAssembly program before `main`. We carry the fix until a goldmark release the site can use no longer compiles them.

### goldmark runs on TinyGo's WebAssembly targets

> Upstream fit: **yes** · [patch 0001](https://neuroplast.io/modding/web/hotty/mods/goldmark/0001-perf-scan-e-mail-domains-and-linkify-s-URLs-without-.patch)

**What it changes:** `util.FindEmailIndex` scans an e-mail address's domain
by hand, as goldmark v2's parser does, and the linkify extension finds URLs
and `www.` links with a scanner instead of its two default regexps. The
scanner finds what the patterns found, and a test checks it against them on
300,000 generated lines. `WithLinkifyURLRegexp` and `WithLinkifyWWWRegexp`
still take a pattern; only the defaults are gone.

**Why we carry it:** goldmark compiled those patterns when its packages
were initialized. Their `{0,61}` and `{1,256}` repeats nest deep enough to
overflow the fixed 64 KB goroutine stacks of TinyGo's WebAssembly targets,
so HOTTY's website, hotty.neuroplast.io, crashed before `main`
([tinygo#3258](https://github.com/tinygo-org/tinygo/issues/3258)).

**For upstream:** yes. goldmark v2 already scans e-mail domains this way
(ea86b6d5); this does it in v1 too, and for linkify's defaults, with no
change to what is found. Every program that imports goldmark stops paying
to compile the patterns at startup.

---

[neuroplast.io](https://neuroplast.io/) · [Modding](https://neuroplast.io/modding) · [github.com/neuroplastio](https://github.com/neuroplastio)
