1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-06 10:00:26 +00:00

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)
This commit is contained in:
Timur Ismagilov 2021-05-24 14:33:57 +05:00
parent fcd4b9b853
commit 4fcf5abb37
5 changed files with 11 additions and 11 deletions

View File

@ -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,

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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)
}
}
}

View File

@ -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