mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Add optional build tag for experimental BEAN Markdown renderer support
This commit is contained in:
@@ -3,6 +3,7 @@ module github.com/rwinkhart/MUTN
|
||||
go 1.23.2
|
||||
|
||||
require (
|
||||
github.com/Trojan2021/BEAN v0.0.0-20241029203751-320edbc990e8
|
||||
github.com/charmbracelet/glamour v0.7.0
|
||||
github.com/rwinkhart/libmutton v0.2.3
|
||||
golang.org/x/term v0.25.0
|
||||
@@ -13,6 +14,7 @@ require (
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/boombuler/barcode v1.0.2 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.4.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||
github.com/fortis/go-steam-totp v0.0.0-20171114202746-18e928674727 // indirect
|
||||
github.com/gorilla/css v1.0.1 // indirect
|
||||
@@ -27,6 +29,7 @@ require (
|
||||
github.com/pkg/sftp v1.13.6 // indirect
|
||||
github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rwinkhart/convertroman v0.2.0 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/yuin/goldmark v1.7.8 // indirect
|
||||
github.com/yuin/goldmark-emoji v1.0.4 // indirect
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
github.com/Trojan2021/BEAN v0.0.0-20241029203751-320edbc990e8 h1:V4m0AESOYQ3rnklgxozXP7BSE2wqTaqVfWati1fGXAo=
|
||||
github.com/Trojan2021/BEAN v0.0.0-20241029203751-320edbc990e8/go.mod h1:mgyhaOTeO5Ba8xMhE4f/E+JrHEUbk7IHKDrt2AXqAWY=
|
||||
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
|
||||
github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||
github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E=
|
||||
@@ -13,6 +15,8 @@ github.com/boombuler/barcode v1.0.2 h1:79yrbttoZrLGkL/oOI8hBrUKucwOL0oOjUgEguGMc
|
||||
github.com/boombuler/barcode v1.0.2/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng=
|
||||
github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps=
|
||||
github.com/charmbracelet/x/ansi v0.4.0 h1:NqwHA4B23VwsDn4H3VcNX1W1tOmgnvY1NDx5tOXdnOU=
|
||||
github.com/charmbracelet/x/ansi v0.4.0/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -52,6 +56,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rwinkhart/convertroman v0.2.0 h1:otUm939eXT77q/Lr31mJtMwVWEw0RjEUB71gO65h9OM=
|
||||
github.com/rwinkhart/convertroman v0.2.0/go.mod h1:Af6HqvX0EIM4Y3HcnNXbbRey1dLasGB7WU0+3Cowgmw=
|
||||
github.com/rwinkhart/libmutton v0.2.3 h1:1oreB+3VQ4g3zy0ZzfCbYvU83Nkg7UCZMaimeBN5+eE=
|
||||
github.com/rwinkhart/libmutton v0.2.3/go.mod h1:z3BxZ8l6osV2HQ8RZ0PjUbPnUFNEbxX59/RMrSW0iLI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
MUTNVersion = "0.2.3" // untagged releases feature a letter suffix corresponding to the eventual release version, e.g "0.2.A" -> "0.2.0", "0.2.B" -> "0.2.1"
|
||||
MUTNVersion = "0.2.E" // untagged releases feature a letter suffix corresponding to the eventual release version, e.g "0.2.A" -> "0.2.0", "0.2.B" -> "0.2.1"
|
||||
|
||||
AnsiBold = "\033[1m"
|
||||
ansiBlackOnWhite = "\033[38;5;0;48;5;15m"
|
||||
|
||||
@@ -3,7 +3,6 @@ package cli
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/rwinkhart/libmutton/core"
|
||||
"github.com/rwinkhart/libmutton/sync"
|
||||
@@ -50,14 +49,13 @@ func EntryReader(decryptedEntry []string, hideSecrets, syncEnabled bool) {
|
||||
fmt.Println(ansiDirectoryHeader + "Notes:" + core.AnsiReset)
|
||||
|
||||
// combine remaining fields into a single string (to support Markdown rendering)
|
||||
var notesSlice []string
|
||||
var noteLines []string
|
||||
for ; field < len(decryptedEntry); field++ {
|
||||
notesSlice = append(notesSlice, decryptedEntry[field])
|
||||
noteLines = append(noteLines, decryptedEntry[field])
|
||||
}
|
||||
joinedString := strings.Join(notesSlice, "\n")
|
||||
|
||||
// print notes to stdout
|
||||
renderNote(&joinedString)
|
||||
renderNote(noteLines)
|
||||
|
||||
// break after notes have been printed
|
||||
break
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//go:build !noMarkdown && BEAN
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
bean "github.com/Trojan2021/BEAN/render"
|
||||
)
|
||||
|
||||
// renderNote renders the notes section of an entry (in Markdown) to stdout.
|
||||
func renderNote(noteLines []string) {
|
||||
fmt.Println(bean.RenderMarkdown(noteLines, width))
|
||||
}
|
||||
@@ -4,9 +4,10 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// renderNote prints the notes section of an entry to stdout (when Markdown rendering is disabled).
|
||||
func renderNote(note *string) {
|
||||
fmt.Print("\n" + *note + "\n\n")
|
||||
func renderNote(noteLines []string) {
|
||||
fmt.Print("\n" + strings.Join(noteLines, "\n") + "\n\n")
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
//go:build !noMarkdown
|
||||
//go:build !noMarkdown && !BEAN
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/glamour"
|
||||
)
|
||||
|
||||
// renderNote renders the notes section of an entry (in Markdown) to stdout.
|
||||
func renderNote(note *string) {
|
||||
func renderNote(noteLines []string) {
|
||||
note := strings.Join(noteLines, "\n")
|
||||
r, _ := glamour.NewTermRenderer(glamour.WithStylesFromJSONBytes(glamourStyle()), glamour.WithPreservedNewLines(), glamour.WithWordWrap(width))
|
||||
markdownNotesString, _ := r.Render(*note)
|
||||
markdownNotesString, _ := r.Render(note)
|
||||
|
||||
// print markdown-rendered notes
|
||||
fmt.Print(markdownNotesString)
|
||||
+2
-1
@@ -5,6 +5,7 @@ CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath ./mutn.go
|
||||
```
|
||||
|
||||
Additionally, some custom build tags can be used to create different binaries. The following tags are not used in official builds:
|
||||
- `noMarkdown`: Creates a binary without Markdown support (much smaller binary size and faster launch time)
|
||||
- `BEAN`: Creates a binary with the experimental [BEAN](https://github.com/Trojan2021/BEAN) Markdown renderer in place of Glamour
|
||||
- `noMarkdown`: Creates a binary without Markdown support (much smaller binary size and faster launch time VS Glamour)
|
||||
- `wsl`: Allows creating a Linux binary that can interact with the Windows clipboard (for WSL)
|
||||
- `termux`: Allows creating a Linux binary that can interact with the Termux clipboard (for Android)
|
||||
|
||||
Reference in New Issue
Block a user