diff --git a/public/parsing.wasm b/public/parsing.wasm index 646301a7..267dc2d1 100755 Binary files a/public/parsing.wasm and b/public/parsing.wasm differ diff --git a/src/config/config.go.example b/src/config/config.go.example index d580f599..ce5e570f 100644 --- a/src/config/config.go.example +++ b/src/config/config.go.example @@ -1,3 +1,5 @@ +//go:build !js + package config import ( diff --git a/src/config/jsconfig.go b/src/config/jsconfig.go new file mode 100644 index 00000000..80eea039 --- /dev/null +++ b/src/config/jsconfig.go @@ -0,0 +1,7 @@ +//go:build js + +package config + +var Config = HMNConfig{ + BaseUrl: "https://handmade.network", +} diff --git a/src/parsing/parsing.go b/src/parsing/parsing.go index b2dae1e1..3b206da9 100644 --- a/src/parsing/parsing.go +++ b/src/parsing/parsing.go @@ -14,6 +14,7 @@ import ( // Used for rendering real-time previews of post content. var ForumPreviewMarkdown = makeGoldmark( + false, goldmark.WithExtensions(makeGoldmarkExtensions(MarkdownOptions{ Previews: true, Embeds: true, @@ -22,6 +23,7 @@ var ForumPreviewMarkdown = makeGoldmark( // Used for generating the final HTML for a post. var ForumRealMarkdown = makeGoldmark( + false, goldmark.WithExtensions(makeGoldmarkExtensions(MarkdownOptions{ Previews: false, Embeds: true, @@ -30,6 +32,7 @@ var ForumRealMarkdown = makeGoldmark( // Used for generating plain-text previews of posts. var PlaintextMarkdown = makeGoldmark( + false, goldmark.WithExtensions(makeGoldmarkExtensions(MarkdownOptions{ Previews: false, Embeds: true, @@ -39,6 +42,7 @@ var PlaintextMarkdown = makeGoldmark( // Used for processing Discord messages var DiscordMarkdown = makeGoldmark( + false, goldmark.WithExtensions(makeGoldmarkExtensions(MarkdownOptions{ Previews: false, Embeds: false, @@ -48,20 +52,24 @@ var DiscordMarkdown = makeGoldmark( // Used for rendering real-time previews of post content. var EducationPreviewMarkdown = makeGoldmark( + true, goldmark.WithExtensions(makeGoldmarkExtensions(MarkdownOptions{ Previews: true, Embeds: true, Education: true, })...), + goldmark.WithRendererOptions(html.WithUnsafe()), ) // Used for generating the final HTML for a post. var EducationRealMarkdown = makeGoldmark( + true, goldmark.WithExtensions(makeGoldmarkExtensions(MarkdownOptions{ Previews: false, Embeds: true, Education: true, })...), + goldmark.WithRendererOptions(html.WithUnsafe()), ) func ParseMarkdown(source string, md goldmark.Markdown) string { @@ -79,8 +87,9 @@ type MarkdownOptions struct { Education bool } -func makeGoldmark(opts ...goldmark.Option) goldmark.Markdown { +func makeGoldmark(rawHTML bool, opts ...goldmark.Option) goldmark.Markdown { // We need to re-create Goldmark's default parsers to disable HTML parsing. + // Or enable it again. yay // See parser.DefaultBlockParsers blockParsers := []util.PrioritizedValue{ @@ -101,10 +110,15 @@ func makeGoldmark(opts ...goldmark.Option) goldmark.Markdown { util.Prioritized(parser.NewCodeSpanParser(), 100), util.Prioritized(parser.NewLinkParser(), 200), util.Prioritized(parser.NewAutoLinkParser(), 300), - //util.Prioritized(parser.NewRawHTMLParser(), 400), + // util.Prioritized(parser.NewRawHTMLParser(), 400), util.Prioritized(parser.NewEmphasisParser(), 500), } + if rawHTML { + blockParsers = append(blockParsers, util.Prioritized(parser.NewHTMLBlockParser(), 900)) + inlineParsers = append(inlineParsers, util.Prioritized(parser.NewRawHTMLParser(), 400)) + } + opts = append(opts, goldmark.WithParser(parser.NewParser( parser.WithBlockParsers(blockParsers...), parser.WithInlineParsers(inlineParsers...), diff --git a/src/parsing/wasm/parsingmain.go b/src/parsing/wasm/parsingmain.go index 5bfea356..9790b4c4 100644 --- a/src/parsing/wasm/parsingmain.go +++ b/src/parsing/wasm/parsingmain.go @@ -16,6 +16,6 @@ func main() { return parsing.ParseMarkdown(args[0].String(), parsing.EducationPreviewMarkdown) })) - var done chan bool + var done chan struct{} <-done // block forever } diff --git a/src/templates/src/education_article.html b/src/templates/src/education_article.html index 0b04d75b..99d98b9b 100644 --- a/src/templates/src/education_article.html +++ b/src/templates/src/education_article.html @@ -5,6 +5,38 @@ .hide-notes .note { display: none; } + + .toc { + position: relative; + overflow: hidden; + transition: all 40ms ease-in-out; + } + + .toc::after { + content: ''; + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + border-left: 0 solid var(--link-color); + transition: all 40ms ease-in-out; + } + + .toc.active { + background-color: var(--dim-background); + } + + .toc.active::after { + border-left-width: 0.25rem; + } + + .toc-1 {} + .toc-2 { margin-left: 1rem; } + .toc-3 { margin-left: 2rem; } + .toc-4 { margin-left: 3rem; } + .toc-5 { margin-left: 4rem; } + .toc-6 { margin-left: 5rem; } {{ end }} @@ -22,12 +54,50 @@