Skip to content

Commit 6b94a78

Browse files
committed
Switch from internal markup package to github.com/git-pkgs/markup
Replace the local internal/markup package with the published module. Same rendering support (Markdown native, external tools for other formats) with a cleaner registry-based API.
1 parent 361c3ff commit 6b94a78

File tree

8 files changed

+25
-727
lines changed

8 files changed

+25
-727
lines changed

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ go 1.25.6
44

55
require (
66
github.com/git-pkgs/changelog v0.1.1
7+
github.com/git-pkgs/markup v0.1.0
78
github.com/go-enry/go-enry/v2 v2.9.2
89
github.com/rs/cors v1.11.1
9-
github.com/yuin/goldmark v1.7.8
1010
)
1111

12-
require github.com/go-enry/go-oniguruma v1.2.1 // indirect
12+
require (
13+
github.com/go-enry/go-oniguruma v1.2.1 // indirect
14+
github.com/niklasfasching/go-org v1.9.1 // indirect
15+
github.com/yuin/goldmark v1.8.2 // indirect
16+
golang.org/x/net v0.45.0 // indirect
17+
)

go.sum

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/git-pkgs/changelog v0.1.1 h1:hGEraBDgwUUQfwV8y6MVS+QywbpcYNAFVtg25LfCnIM=
55
github.com/git-pkgs/changelog v0.1.1/go.mod h1:psv6VJyJKYzDYajKdV9oPw7LUEOIqSiB0L3wcKdX6Ac=
6+
github.com/git-pkgs/markup v0.1.0 h1:y4MB7bWE6Txz68c0WnR0UykV5NxCDXMgrgdIEuukYUU=
7+
github.com/git-pkgs/markup v0.1.0/go.mod h1:301O9D4beTPZjJMxMfRsLrk2cUzNoPPBj8bmLdhRaZU=
68
github.com/go-enry/go-enry/v2 v2.9.2 h1:giOQAtCgBX08kosrX818DCQJTCNtKwoPBGu0qb6nKTY=
79
github.com/go-enry/go-enry/v2 v2.9.2/go.mod h1:9yrj4ES1YrbNb1Wb7/PWYr2bpaCXUGRt0uafN0ISyG8=
810
github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo=
911
github.com/go-enry/go-oniguruma v1.2.1/go.mod h1:bWDhYP+S6xZQgiRL7wlTScFYBe023B6ilRZbCAD5Hf4=
12+
github.com/niklasfasching/go-org v1.9.1 h1:/3s4uTPOF06pImGa2Yvlp24yKXZoTYM+nsIlMzfpg/0=
13+
github.com/niklasfasching/go-org v1.9.1/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48=
1014
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1115
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1216
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
@@ -18,8 +22,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
1822
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1923
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
2024
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
21-
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
22-
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
25+
github.com/yuin/goldmark v1.8.2 h1:kEGpgqJXdgbkhcOgBxkC0X0PmoPG1ZyoZ117rDVp4zE=
26+
github.com/yuin/goldmark v1.8.2/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
27+
golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM=
28+
golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
2329
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2430
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2531
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/archive/readme.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"sort"
99
"strings"
1010

11-
"github.com/ecosyste-ms/archives/internal/markup"
11+
"github.com/git-pkgs/markup"
1212
"github.com/go-enry/go-enry/v2"
1313
)
1414

@@ -215,12 +215,14 @@ func (a *RemoteArchive) Changelog() (*ChangelogResult, error) {
215215
}, nil
216216
}
217217

218+
var markupRegistry = markup.NewDefaultRegistry()
219+
218220
// renderFile uses the markup package to render a file to HTML.
219221
// Falls back to go-enry for language detection if markup doesn't handle the format.
220-
func renderFile(filename string, content []byte) (html string, language string) {
221-
result, ok := markup.Render(filename, content)
222-
if ok {
223-
return result.HTML, result.Language
222+
func renderFile(filename string, content []byte) (htmlStr string, language string) {
223+
result, err := markupRegistry.Render(filename, content)
224+
if err == nil {
225+
return result.HTML, result.Format.String()
224226
}
225227
// Format not supported by markup package, return empty HTML
226228
lang := detectLanguage(filename, content)

internal/archive/readme_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package archive
33
import (
44
"testing"
55

6-
"github.com/ecosyste-ms/archives/internal/markup"
6+
"github.com/git-pkgs/markup"
77
)
88

99
func TestRenderFileMarkdown(t *testing.T) {
@@ -24,7 +24,8 @@ func TestRenderFileUnknown(t *testing.T) {
2424
}
2525

2626
func TestRenderFileAsciiDoc(t *testing.T) {
27-
if !markup.Supported(markup.FormatAsciiDoc) {
27+
reg := markup.NewDefaultRegistry()
28+
if !reg.Supported("README.adoc") {
2829
t.Skip("asciidoctor not installed")
2930
}
3031
html, lang := renderFile("README.adoc", []byte("= Hello\n\nWorld\n"))

internal/markup/external.go

Lines changed: 0 additions & 184 deletions
This file was deleted.

internal/markup/markdown.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)