From 4fcf5abb37e51467d9e5f0936fac61789a436a23 Mon Sep 17 00:00:00 2001 From: Timur Ismagilov Date: Mon, 24 May 2021 14:33:57 +0500 Subject: [PATCH] Migrate to mycomarkup v0.3.0 Break a lot of things as well: * OpenGraph is temporarily removed * Link coloring is broken * RocketLink display text is lost for some reason * List nesting is lost? Some things got fixed though: * External link icons are back And new features: * Multiline list entries (tasty) --- cfg/header_links.go | 8 +++++--- go.mod | 2 +- go.sum | 4 ++-- shroom/view.go | 4 +--- web/readers.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cfg/header_links.go b/cfg/header_links.go index 7afb3f6..b6add82 100644 --- a/cfg/header_links.go +++ b/cfg/header_links.go @@ -2,6 +2,7 @@ package cfg // See https://mycorrhiza.lesarbr.es/hypha/configuration/header import ( + "github.com/bouncepaw/mycomarkup/blocks" "strings" ) @@ -18,8 +19,8 @@ func SetDefaultHeaderLinks() { } } -// ParseHeaderLinks extracts all rocketlinks from the given text and saves them as header links. rocketlinkλ must be set to markup.Rocketlink. You have to pass it like that to avoid cyclical dependency. -func ParseHeaderLinks(text string, rocketlinkλ func(string, string) (string, string, string)) { +// ParseHeaderLinks extracts all rocketlinks from the given text and saves them as header links. +func ParseHeaderLinks(text string) { HeaderLinks = []HeaderLink{} for _, line := range strings.Split(text, "\n") { // There is a false positive when parsing markup like that: @@ -30,7 +31,8 @@ func ParseHeaderLinks(text string, rocketlinkλ func(string, string) (string, st // // I do not really care. if strings.HasPrefix(line, "=>") { - href, display, _ := rocketlinkλ(line, HeaderLinksHypha) + rl := blocks.MakeRocketLink(line, HeaderLinksHypha) + href, display := rl.Href(), rl.Display() HeaderLinks = append(HeaderLinks, HeaderLink{ Href: href, Display: display, diff --git a/go.mod b/go.mod index 778bbb1..ed833b5 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.14 require ( git.sr.ht/~adnano/go-gemini v0.1.13 github.com/adrg/xdg v0.2.2 - github.com/bouncepaw/mycomarkup v0.1.0 + github.com/bouncepaw/mycomarkup v0.3.1 github.com/go-ini/ini v1.62.0 github.com/gorilla/feeds v1.1.1 github.com/kr/pretty v0.2.1 // indirect diff --git a/go.sum b/go.sum index 37c9e73..d74a34a 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ git.sr.ht/~adnano/go-gemini v0.1.13/go.mod h1:If1VxEWcZDrRt5FeAFnGTcM2Ud1E3BXs3V github.com/adrg/xdg v0.2.2 h1:A7ZHKRz5KGOLJX/bg7IPzStryhvCzAE1wX+KWawPiAo= github.com/adrg/xdg v0.2.2/go.mod h1:7I2hH/IT30IsupOpKZ5ue7/qNi3CoKzD6tL3HwpaRMQ= github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= -github.com/bouncepaw/mycomarkup v0.1.0 h1:WsvWe1+ygGXexjjLo1Gq7Qxh7INkLZ9YCjj4SjZOUk4= -github.com/bouncepaw/mycomarkup v0.1.0/go.mod h1:0n6thlGGgrx2Y/2NaaUH4qHW4v1xJ+EpW7yMFUxNRIg= +github.com/bouncepaw/mycomarkup v0.3.1 h1:5uh7PJYjTNqrA2ibZAvA50nImKECq5AWtlzTEOO32sM= +github.com/bouncepaw/mycomarkup v0.3.1/go.mod h1:0n6thlGGgrx2Y/2NaaUH4qHW4v1xJ+EpW7yMFUxNRIg= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-ini/ini v1.62.0 h1:7VJT/ZXjzqSrvtraFp4ONq80hTcRQth1c9ZnQ3uNQvU= diff --git a/shroom/view.go b/shroom/view.go index 444db3b..ce7a8f4 100644 --- a/shroom/view.go +++ b/shroom/view.go @@ -6,8 +6,6 @@ import ( "github.com/bouncepaw/mycorrhiza/cfg" "github.com/bouncepaw/mycorrhiza/hyphae" - - "github.com/bouncepaw/mycomarkup/blocks" ) // FetchTextPart tries to read text file of the given hypha. If there is no file, empty string is returned. @@ -33,7 +31,7 @@ func SetHeaderLinks() { cfg.SetDefaultHeaderLinks() } else { text := string(contents) - cfg.ParseHeaderLinks(text, blocks.Rocketlink) + cfg.ParseHeaderLinks(text) } } } diff --git a/web/readers.go b/web/readers.go index ecc2e5d..0e04e11 100644 --- a/web/readers.go +++ b/web/readers.go @@ -83,7 +83,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { ) w.Header().Set("Content-Type", "text/html;charset=utf-8") w.WriteHeader(http.StatusOK) - w.Write([]byte(views.BaseHTML(util.BeautifulName(hyphaName), page, u))) + _, _ = fmt.Fprint(w, views.BaseHTML(util.BeautifulName(hyphaName), page, u)) } // handlerText serves raw source text of the hypha. @@ -124,7 +124,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { if errT == nil { md := doc.Doc(hyphaName, string(fileContentsT)) contents = md.AsHTML() - openGraph = md.OpenGraphHTML() + //openGraph = md.OpenGraphHTML() } if !os.IsNotExist(errB) { contents = views.AttachmentHTML(h) + contents