From 981d6ef2f23788bdb61f24682fc5e1176010c9dd Mon Sep 17 00:00:00 2001 From: monopole Date: Sun, 13 Oct 2024 08:05:46 -0700 Subject: [PATCH] Update goldmark dep and add table styling. --- go.mod | 5 +- go.sum | 20 ++++++- internal/parsren/usegold/gparser.go | 44 ++++++++++----- .../{myfcbrenderer.go => mdripcbrenderer.go} | 16 +++--- ...myfencedcodeblock.go => mdripcodeblock.go} | 53 +++++++++++-------- internal/web/app/widget/common/common.css | 11 +++- internal/web/app/widget/helpbox/helpbox.html | 2 +- internal/web/server/dataloader.go | 2 +- 8 files changed, 105 insertions(+), 48 deletions(-) rename internal/web/app/widget/codeblock/{myfcbrenderer.go => mdripcbrenderer.go} (60%) rename internal/web/app/widget/codeblock/{myfencedcodeblock.go => mdripcodeblock.go} (63%) diff --git a/go.mod b/go.mod index 29206fc..2046939 100644 --- a/go.mod +++ b/go.mod @@ -12,12 +12,15 @@ require ( github.com/stretchr/testify v1.9.0 github.com/tdewolff/minify/v2 v2.20.37 github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 - github.com/yuin/goldmark v1.6.0 + github.com/yuin/goldmark v1.7.6 + github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc go.abhg.dev/goldmark/mermaid v0.5.0 ) require ( + github.com/alecthomas/chroma/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/dlclark/regexp2 v1.7.0 // indirect github.com/gorilla/securecookie v1.1.2 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect diff --git a/go.sum b/go.sum index d2750d7..0588b02 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,7 @@ +github.com/alecthomas/chroma/v2 v2.2.0 h1:Aten8jfQwUqEdadVFFjNyjx7HTexhKP0XuqBG67mRDY= +github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs= +github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY= +github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/chromedp/cdproto v0.0.0-20230220211738-2b1ec77315c9 h1:wMSvdj3BswqfQOXp2R1bJOAE7xIQLt2dlMQDMf836VY= @@ -7,8 +11,13 @@ github.com/chromedp/chromedp v0.9.1/go.mod h1:DUgZWRvYoEfgi66CgZ/9Yv+psgi+Sksy5D github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= +github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= @@ -35,6 +44,7 @@ github.com/monopole/shexec v0.2.0 h1:hNTn1DAzojIwUmTRNUNMmMkAKO75m+96g1Y3Sicdosg github.com/monopole/shexec v0.2.0/go.mod h1:WQTygUMAUHxvRnjbV92YZSKMED6IUAgTFLY1PqVA2cc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -44,6 +54,8 @@ github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tdewolff/minify/v2 v2.20.37 h1:Q97cx4STXCh1dlWDlNHZniE8BJ2EBL0+2b0n92BJQhw= @@ -55,8 +67,11 @@ github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03 github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4 h1:0sw0nJM544SpsihWx1bkXdYLQDlzRflMgFJQ4Yih9ts= github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4/go.mod h1:+ccdNT0xMY1dtc5XBxumbYfOUhmduiGudqaDgD2rVRE= -github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= -github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.4.15/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.6 h1:cZgJxVh5mL5cu8KOnwxvFJy5TFB0BHUskZZyq7TYbDg= +github.com/yuin/goldmark v1.7.6/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc h1:+IAOyRda+RLrxa1WC7umKOZRsGq4QrFFMYApOeHzQwQ= +github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc/go.mod h1:ovIvrum6DQJA4QsJSovrkC4saKHQVs7TvcaeO8AIl5I= go.abhg.dev/goldmark/mermaid v0.5.0 h1:mDkykpSPJ+5wCQ8bSXgzJ2KQskjXkI5Ndxz7JYDHW38= go.abhg.dev/goldmark/mermaid v0.5.0/go.mod h1:OCyk2o85TX2drWHH+HRy6bih2yZlUwbbv/R1MMh1YLs= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= @@ -68,5 +83,6 @@ golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/parsren/usegold/gparser.go b/internal/parsren/usegold/gparser.go index 1b3ceeb..443dabc 100644 --- a/internal/parsren/usegold/gparser.go +++ b/internal/parsren/usegold/gparser.go @@ -1,5 +1,12 @@ package usegold +// For a table of contents (inserted before title) +// "go.abhg.dev/goldmark/toc" +// For code highlighting, we'd like to use +// highlighting "github.com/yuin/goldmark-highlighting/v2" +// chromahtml "github.com/alecthomas/chroma/v2/formatters/html" +// But see the comment on codeblock.MdRipCodeBlock + import ( "bytes" "fmt" @@ -7,12 +14,11 @@ import ( "log/slog" "strings" - "go.abhg.dev/goldmark/mermaid" - "github.com/monopole/mdrip/v2/internal/loader" "github.com/monopole/mdrip/v2/internal/parsren" "github.com/monopole/mdrip/v2/internal/web/app/widget/codeblock" "github.com/yuin/goldmark" + highlighting "github.com/yuin/goldmark-highlighting/v2" "github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/extension" "github.com/yuin/goldmark/parser" @@ -20,6 +26,7 @@ import ( "github.com/yuin/goldmark/renderer/html" "github.com/yuin/goldmark/text" "github.com/yuin/goldmark/util" + "go.abhg.dev/goldmark/mermaid" ) // GParser implements MdParserRenderer @@ -48,12 +55,22 @@ type GParser struct { func NewGParser() *GParser { gp := goldmark.New( + goldmark.WithParserOptions( + parser.WithAutoHeadingID(), + ), goldmark.WithExtensions( extension.GFM, + extension.DefinitionList, + + // These done'nt work r.n. because mermaid diagrams + // appear in fencedcodeblocks; see codeblock.MdRipCodeBlock + highlighting.Highlighting, &mermaid.Extender{}, - ), - goldmark.WithParserOptions( - parser.WithAutoHeadingID(), + + // This works, but slaps the toc above the title (ugly). + //&toc.Extender{ + // Title: "Contents", + //}, ), goldmark.WithRendererOptions( // html.WithHardWraps(), @@ -63,8 +80,9 @@ func NewGParser() *GParser { ) const priority = 100 gp.Renderer().AddOptions( + // See comment on the codeblock.MdRipCodeBlock type. renderer.WithNodeRenderers( - util.Prioritized(&codeblock.MyFcbRenderer{}, priority)), + util.Prioritized(&codeblock.MdRipCbRenderer{}, priority)), ) return &GParser{ p: gp, @@ -114,7 +132,7 @@ func (v *GParser) VisitFile(fi *loader.MyFile) { // of the bytes. node := v.p.Parser().Parse(text.NewReader(fi.C())) - fencedBlocks, err := gatherMyFencedCodeBlocks(node) + fencedBlocks, err := gatherMdRipCodeBlocks(node) if err != nil && v.err == nil { v.err = err } @@ -141,8 +159,8 @@ func (v *GParser) VisitFile(fi *loader.MyFile) { v.renderMdFiles = append(v.renderMdFiles, rf) } -func gatherMyFencedCodeBlocks(n ast.Node) ( - result []*codeblock.MyFencedCodeBlock, err error) { +func gatherMdRipCodeBlocks(n ast.Node) ( + result []*codeblock.MdRipCodeBlock, err error) { var originals []*ast.FencedCodeBlock err = ast.Walk( n, @@ -162,7 +180,7 @@ func gatherMyFencedCodeBlocks(n ast.Node) ( } return ast.WalkContinue, nil }) - result = make([]*codeblock.MyFencedCodeBlock, len(originals)) + result = make([]*codeblock.MdRipCodeBlock, len(originals)) for i := range originals { // The following messes with the AST, so we don't want to // do it *during* the Walk, only *after* the Walk. @@ -171,8 +189,8 @@ func gatherMyFencedCodeBlocks(n ast.Node) ( return } -func swapOutTheirCodeBlockForMine(n *ast.FencedCodeBlock) *codeblock.MyFencedCodeBlock { - mine := codeblock.NewMyFencedCodeBlock(n) +func swapOutTheirCodeBlockForMine(n *ast.FencedCodeBlock) *codeblock.MdRipCodeBlock { + mine := codeblock.NewMdRipCodeBlock(n) n.Parent().ReplaceChild(n.Parent(), n, mine) return mine } @@ -195,7 +213,7 @@ func (v *GParser) renderMdFile( } func (v *GParser) convertFcbToCb( - fcb *codeblock.MyFencedCodeBlock, index int) *loader.CodeBlock { + fcb *codeblock.MdRipCodeBlock, index int) *loader.CodeBlock { cb := loader.NewCodeBlock( v.currentFile, v.nodeText(fcb), index, string(fcb.Language(v.currentFile.C()))) diff --git a/internal/web/app/widget/codeblock/myfcbrenderer.go b/internal/web/app/widget/codeblock/mdripcbrenderer.go similarity index 60% rename from internal/web/app/widget/codeblock/myfcbrenderer.go rename to internal/web/app/widget/codeblock/mdripcbrenderer.go index c398ecb..38ea7e6 100644 --- a/internal/web/app/widget/codeblock/myfcbrenderer.go +++ b/internal/web/app/widget/codeblock/mdripcbrenderer.go @@ -7,29 +7,29 @@ import ( "github.com/yuin/goldmark/util" ) -// MyFcbRenderer is an implementation of renderer.NodeRenderer, but despite +// MdRipCbRenderer is an implementation of renderer.NodeRenderer, but despite // the name of the interface, instances of this don't actually render // anything. All an instance does is provide a method that registers // a "Kind" with a rendering function. The rendering function can live -// anywhere, and in this case it lives in an instance of MyFencedCodeBlock. +// anywhere, and in this case it lives in an instance of MdRipCodeBlock. // This all seems odd, but it appears to work. -type MyFcbRenderer struct { +type MdRipCbRenderer struct { Writer html.Writer } // Proof of interface implementation. -var _ renderer.NodeRenderer = &MyFcbRenderer{} +var _ renderer.NodeRenderer = &MdRipCbRenderer{} // RegisterFuncs implements NodeRenderer.RegisterFuncs. -func (r *MyFcbRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) { - reg.Register(kindMyFencedCodeBlock, callMyFencedCodeBlockRender) +func (r *MdRipCbRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) { + reg.Register(kindMdRipCodeBlock, callMdRipCodeBlockRender) } -func callMyFencedCodeBlockRender( +func callMdRipCodeBlockRender( w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error) { if entering { - node.(*MyFencedCodeBlock).render(w, source) + node.(*MdRipCodeBlock).render(w, source) } return ast.WalkContinue, nil } diff --git a/internal/web/app/widget/codeblock/myfencedcodeblock.go b/internal/web/app/widget/codeblock/mdripcodeblock.go similarity index 63% rename from internal/web/app/widget/codeblock/myfencedcodeblock.go rename to internal/web/app/widget/codeblock/mdripcodeblock.go index 30cb09b..447d366 100644 --- a/internal/web/app/widget/codeblock/myfencedcodeblock.go +++ b/internal/web/app/widget/codeblock/mdripcodeblock.go @@ -11,23 +11,23 @@ import ( ) var ( - // kindMyFencedCodeBlock is a NodeKind of the MyFencedCodeBlock node. - kindMyFencedCodeBlock = ast.NewNodeKind("MyFencedCodeBlock") + // kindMdRipCodeBlock is a NodeKind of the MdRipCodeBlock node. + kindMdRipCodeBlock = ast.NewNodeKind("MdRipCodeBlock") codeBlockTemplate = common.MustHtmlTemplate(AsTmpl()) ) -// A MyFencedCodeBlock struct represents a fenced code block of Markdown text. +// A MdRipCodeBlock struct represents a fenced code block of Markdown text. // // Sometimes we want to render a fenced code block using the normal default // fenced code block rendered, e.g. when a code block is "protected" inside a // blockquote. // -// But more often we want to do a special rendering, that encourages copy/paste, +// But sometimes we want to do a special rendering, that encourages copy/paste, // execution, etc. // // When we do want a special rendering, we replace the AST node instance of a -// native FencedCodeBlock with an instance of MyFencedCodeBlock. The latter +// native FencedCodeBlock with an instance of MdRipCodeBlock. The latter // must register its own Kind and renderer with the goldmark infrastructure. // // FWIW, in goldMark's interfaces, there doesn't seem to be a way to call a @@ -39,21 +39,32 @@ var ( // held inside the encapsulating renderer // - the private "renderFencedCodeBlock" function // near goldmark/renderer/html/html.go:L386 -type MyFencedCodeBlock struct { +// +// Annoyingly, since we replace the FencedCodeBlock with MdRipCodeBlock, +// the goldmark code highlighter won't be invoked. +// +// TODO: rebuild the AST so that instead of replacing a FencedCodeBLock +// +// with a MdRipCodeBlock, we nest the FencedCodeBlock inside the +// MdRipCodeBlock. +type MdRipCodeBlock struct { ast.FencedCodeBlock } -// NewMyFencedCodeBlock return a new MyFencedCodeBlock node. -func NewMyFencedCodeBlock(fcb *ast.FencedCodeBlock) *MyFencedCodeBlock { - return &MyFencedCodeBlock{*fcb} +// NewMdRipCodeBlock return a new MdRipCodeBlock AST node. +func NewMdRipCodeBlock(fcb *ast.FencedCodeBlock) *MdRipCodeBlock { + return &MdRipCodeBlock{*fcb} } // Kind implements Node.Kind. -func (n *MyFencedCodeBlock) Kind() ast.NodeKind { - return kindMyFencedCodeBlock +func (n *MdRipCodeBlock) Kind() ast.NodeKind { + return kindMdRipCodeBlock } -func (n *MyFencedCodeBlock) render(w util.BufWriter, source []byte) { +// render renders a MdRipCodeBlock with the id and styling elements needed +// get something that both looks like a terminal and is properly +// hooked up to the "copy and post for execution" javascript. +func (n *MdRipCodeBlock) render(w util.BufWriter, source []byte) { id, err := n.GetBlockIndex() if err != nil { _, _ = w.WriteString(err.Error()) @@ -81,7 +92,7 @@ func (n *MyFencedCodeBlock) render(w util.BufWriter, source []byte) { } } -func (n *MyFencedCodeBlock) grabNodeText(source []byte) string { +func (n *MdRipCodeBlock) grabNodeText(source []byte) string { var buff strings.Builder numLines := n.Lines().Len() for i := 0; i < numLines; i++ { @@ -100,27 +111,27 @@ const ( attrBlockTitle = "attrBlockTitle" ) -func (n *MyFencedCodeBlock) SetFileIndex(i int) { +func (n *MdRipCodeBlock) SetFileIndex(i int) { n.SetAttributeString(attrFileIdx, i) } -func (n *MyFencedCodeBlock) SetBlockIndex(i int) { +func (n *MdRipCodeBlock) SetBlockIndex(i int) { n.SetAttributeString(attrBlockIdx, i) } -func (n *MyFencedCodeBlock) GetBlockIndex() (int, error) { +func (n *MdRipCodeBlock) GetBlockIndex() (int, error) { return n.getIntAttribute(attrBlockIdx) } -func (n *MyFencedCodeBlock) SetTitle(s string) { +func (n *MdRipCodeBlock) SetTitle(s string) { n.SetAttributeString(attrBlockTitle, s) } -func (n *MyFencedCodeBlock) GetTitle() (string, error) { +func (n *MdRipCodeBlock) GetTitle() (string, error) { return n.getStrAttribute(attrBlockTitle) } -func (n *MyFencedCodeBlock) getIntAttribute(name string) (int, error) { +func (n *MdRipCodeBlock) getIntAttribute(name string) (int, error) { tmp, err := n.getRawAttribute(name) if err != nil { return 0, err @@ -133,7 +144,7 @@ func (n *MyFencedCodeBlock) getIntAttribute(name string) (int, error) { return result, nil } -func (n *MyFencedCodeBlock) getStrAttribute(name string) (string, error) { +func (n *MdRipCodeBlock) getStrAttribute(name string) (string, error) { tmp, err := n.getRawAttribute(name) if err != nil { return "", err @@ -146,7 +157,7 @@ func (n *MyFencedCodeBlock) getStrAttribute(name string) (string, error) { return result, nil } -func (n *MyFencedCodeBlock) getRawAttribute(name string) (any, error) { +func (n *MdRipCodeBlock) getRawAttribute(name string) (any, error) { tmp, ok := n.AttributeString(name) if !ok { return "", fmt.Errorf( diff --git a/internal/web/app/widget/common/common.css b/internal/web/app/widget/common/common.css index 806c5ef..23e38c2 100644 --- a/internal/web/app/widget/common/common.css +++ b/internal/web/app/widget/common/common.css @@ -26,7 +26,7 @@ --color-code-background: black; --color-code-active: #23ff56; /* terminal green */ --color-code-inactive: #10aa10; /* terminal green */ - --color-code-checkmark: #00b7eb; /* powedr blue */ + --color-code-checkmark: #00b7eb; /* powder blue */ --color-code-shadow: rgba(10, 100, 10, 0.85); /* dark green with some transparency */ --color-code-label: #404040; @@ -57,6 +57,15 @@ blockquote p { display: inline; } +table, th, td { + border: 1px solid var(--color-code-label); + border-collapse: collapse; +} + +th, td { + padding: 0.3em 1em; +} + body { padding: 0; margin: 0; diff --git a/internal/web/app/widget/helpbox/helpbox.html b/internal/web/app/widget/helpbox/helpbox.html index ca6f0a7..2511fd3 100644 --- a/internal/web/app/widget/helpbox/helpbox.html +++ b/internal/web/app/widget/helpbox/helpbox.html @@ -1,7 +1,7 @@

- Markdown source: {{.AppState.DataSource}} + Markdown from {{.AppState.DataSource}}

Keys

diff --git a/internal/web/server/dataloader.go b/internal/web/server/dataloader.go index e8b8a6d..8279f14 100644 --- a/internal/web/server/dataloader.go +++ b/internal/web/server/dataloader.go @@ -27,7 +27,7 @@ type DataLoader struct { appState *appstate.AppState } -const maxAge = 5 * time.Minute +const maxAge = 30 * time.Second func NewDataLoader( ldr *loader.FsLoader, paths []string,