Skip to content

Commit

Permalink
fix: linting of markdown builder
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Aug 21, 2024
1 parent 87c2cae commit acb6b27
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/yuin/goldmark-emoji v1.0.3
github.com/zeiss/fiber-authz v1.0.33
github.com/zeiss/fiber-goth v1.2.11
github.com/zeiss/fiber-htmx v1.3.23-0.20240820124124-f7a6581f42db
github.com/zeiss/fiber-htmx v1.3.23-0.20240820190014-467e0c915cd4
github.com/zeiss/gorm-seed v0.1.2
github.com/zeiss/pkg v0.1.8-0.20240820132257-62fb0d68df14
go.abhg.dev/goldmark/mermaid v0.5.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ github.com/zeiss/fiber-goth v1.2.11 h1:24EiIKF1iPrmlspbW/BylcqVyj4Ltwzmx9DM7pRs6
github.com/zeiss/fiber-goth v1.2.11/go.mod h1:9NuXxIeKZgmk3dfl7HWbZK/eAfukvjMCHHacGo0m84Y=
github.com/zeiss/fiber-htmx v1.3.23-0.20240820124124-f7a6581f42db h1:LsoTH81Zk3+3AxkcAKUlWTSZ/0IW5xm2DOmxCzXwR2Q=
github.com/zeiss/fiber-htmx v1.3.23-0.20240820124124-f7a6581f42db/go.mod h1:AxDHhpJAyRpqRC3PlHl2CgF/68oVMqkR9G7tLXouL4s=
github.com/zeiss/fiber-htmx v1.3.23-0.20240820190014-467e0c915cd4 h1:eOlaDpiPS0Bo1y3KhvzAqXNxEO+zJ2yAXjKGoz7y6Zc=
github.com/zeiss/fiber-htmx v1.3.23-0.20240820190014-467e0c915cd4/go.mod h1:AxDHhpJAyRpqRC3PlHl2CgF/68oVMqkR9G7tLXouL4s=
github.com/zeiss/gorm-seed v0.1.2 h1:XksLz/IXC1ejUgbl5dHC2/vQAqD2LNZMhZMz2w+E7fY=
github.com/zeiss/gorm-seed v0.1.2/go.mod h1:Tli6ekFpRjtQY8S6VoNiLgRnX1DVEvHJkf+UI85kV+E=
github.com/zeiss/pkg v0.1.8-0.20240820132257-62fb0d68df14 h1:Tl0expErjEbHsQTiaP290aXjKuYve523ULwBU40wtck=
Expand Down
4 changes: 2 additions & 2 deletions internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *MarkdownBuilder) List(w util.BufWriter, source []byte, node ast.Node, e
if entering {
_ = w.WriteByte('<')
_, _ = w.WriteString(tag)
_, _ = w.Write([]byte(" " + "class" + `="` + template.HTMLEscapeString(classes) + `"`))
_, _ = w.WriteString(" class=\"" + template.HTMLEscapeString(classes) + "\"")

if n.IsOrdered() && n.Start != 1 {
_, _ = fmt.Fprintf(w, " start=\"%d\"", n.Start)
Expand All @@ -131,7 +131,7 @@ func (r *MarkdownBuilder) Heading(w util.BufWriter, source []byte, node ast.Node
if entering {
_, _ = w.WriteString("<h")
_ = w.WriteByte("0123456"[n.Level])
_, _ = w.Write([]byte(" " + "class" + `="` + template.HTMLEscapeString(HeadingClasses[n.Level]) + `"`))
_, _ = w.WriteString(" class=\"" + template.HTMLEscapeString(HeadingClasses[n.Level]) + "\"")

if n.Attributes() != nil {
html.RenderAttributes(w, node, html.HeadingAttributeFilter)
Expand Down
11 changes: 8 additions & 3 deletions internal/components/designs/design-title-card.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package designs
import (
"fmt"

"github.com/zeiss/service-lens/internal/models"
"github.com/zeiss/service-lens/internal/utils"

htmx "github.com/zeiss/fiber-htmx"
"github.com/zeiss/fiber-htmx/components/buttons"
"github.com/zeiss/fiber-htmx/components/cards"
"github.com/zeiss/fiber-htmx/components/tailwind"
"github.com/zeiss/service-lens/internal/models"
"github.com/zeiss/service-lens/internal/utils"
"github.com/zeiss/fiber-htmx/components/typography"
)

// DesignTitleCardProps ...
Expand All @@ -33,7 +35,10 @@ func DesignTitleCard(props DesignTitleCardProps) htmx.Node {
htmx.ID("title"),
cards.Body(
cards.BodyProps{},
htmx.H1(htmx.Text(props.Design.Title)),
typography.H2(
typography.Props{},
htmx.Text(props.Design.Title),
),
cards.Actions(
cards.ActionsProps{},
buttons.Button(
Expand Down
4 changes: 4 additions & 0 deletions internal/controllers/designs/edit/body/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import (

"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/renderer"
"github.com/yuin/goldmark/renderer/html"
"github.com/yuin/goldmark/util"
"github.com/zeiss/fiber-htmx/components/buttons"
"github.com/zeiss/fiber-htmx/components/cards"
"github.com/zeiss/fiber-htmx/components/toasts"
seed "github.com/zeiss/gorm-seed"
"github.com/zeiss/service-lens/internal/builder"
"github.com/zeiss/service-lens/internal/models"
"github.com/zeiss/service-lens/internal/ports"
"github.com/zeiss/service-lens/internal/utils"
Expand Down Expand Up @@ -69,6 +72,7 @@ func (l *UpdateControllerImpl) Prepare() error {
goldmark.WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
renderer.WithNodeRenderers(util.Prioritized(builder.NewMarkdownBuilder(), 1)),
),
goldmark.WithExtensions(
extension.GFM,
Expand Down
4 changes: 4 additions & 0 deletions internal/controllers/previews/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
"github.com/yuin/goldmark"
emoji "github.com/yuin/goldmark-emoji"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/renderer"
"github.com/yuin/goldmark/renderer/html"
"github.com/yuin/goldmark/util"
seed "github.com/zeiss/gorm-seed"
"github.com/zeiss/service-lens/internal/builder"
"github.com/zeiss/service-lens/internal/ports"
"go.abhg.dev/goldmark/mermaid"

Expand Down Expand Up @@ -43,6 +46,7 @@ func (m *PreviewControllerImpl) Post() error {
goldmark.WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
renderer.WithNodeRenderers(util.Prioritized(builder.NewMarkdownBuilder(), 1)),
),
goldmark.WithExtensions(
extension.GFM,
Expand Down
4 changes: 4 additions & 0 deletions internal/controllers/templates/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"

"github.com/zeiss/service-lens/internal/builder"
"github.com/zeiss/service-lens/internal/components"
"github.com/zeiss/service-lens/internal/components/templates"
"github.com/zeiss/service-lens/internal/models"
Expand All @@ -12,7 +13,9 @@ import (
"github.com/yuin/goldmark"
emoji "github.com/yuin/goldmark-emoji"
"github.com/yuin/goldmark/extension"
"github.com/yuin/goldmark/renderer"
"github.com/yuin/goldmark/renderer/html"
"github.com/yuin/goldmark/util"
htmx "github.com/zeiss/fiber-htmx"
seed "github.com/zeiss/gorm-seed"
"go.abhg.dev/goldmark/mermaid"
Expand Down Expand Up @@ -55,6 +58,7 @@ func (l *ShowTemplateControllerImpl) Get() error {
goldmark.WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
renderer.WithNodeRenderers(util.Prioritized(builder.NewMarkdownBuilder(), 1)),
),
goldmark.WithExtensions(
extension.GFM,
Expand Down
6 changes: 1 addition & 5 deletions internal/controllers/workloads/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ func (w *WorkloadNewControllerImpl) Get() error {
},
},
cards.Body(
cards.BodyProps{
ClassNames: htmx.ClassNames{
tailwind.M2: true,
},
},
cards.BodyProps{},
forms.FormControl(
forms.FormControlProps{},
forms.FormControlLabel(
Expand Down

0 comments on commit acb6b27

Please sign in to comment.