Skip to content

Commit

Permalink
Yarn upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
earthboundkid committed Dec 2, 2024
1 parent 9609ef4 commit a8107af
Show file tree
Hide file tree
Showing 4 changed files with 388 additions and 381 deletions.
16 changes: 10 additions & 6 deletions internal/blocko/blocko.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"fmt"
"strings"

htmltomarkdown "github.com/JohannesKaufmann/html-to-markdown/v2"

Check failure on line 8 in internal/blocko/blocko.go

View workflow job for this annotation

GitHub Actions / Build

no required module provides package github.com/JohannesKaufmann/html-to-markdown/v2; to add it:
"github.com/spotlightpa/almanack/internal/must"
"github.com/spotlightpa/almanack/internal/xhtml"
"golang.org/x/net/html"
"golang.org/x/net/html/atom"
Expand All @@ -20,14 +22,16 @@ func MinifyAndBlockize(htmlstr string) (string, error) {
}

func Blockize(root *html.Node) string {
Clean(root)
b := must.Get(htmltomarkdown.ConvertNode(root))
return string(b)
// Clean(root)

var blocks []string
for p := root.FirstChild; p != nil; p = p.NextSibling {
blocks = append(blocks, blockToStrings(p)...)
}
// var blocks []string
// for p := root.FirstChild; p != nil; p = p.NextSibling {
// blocks = append(blocks, blockToStrings(p)...)
// }

return strings.Join(blocks, "\n\n") + "\n"
// return strings.Join(blocks, "\n\n") + "\n"
}

func blockToStrings(p *html.Node) []string {
Expand Down
2 changes: 1 addition & 1 deletion internal/blocko/blocko_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ func TestGoldenFiles(t *testing.T) {
got, err := blocko.MinifyAndBlockize(in)
be.NilErr(t, err)

testfile.Equal(t, bareName+".md", got)
testfile.Equalish(t, bareName+".md", got)
})
}
23 changes: 23 additions & 0 deletions internal/xhtml/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,26 @@ func WithAtom(a atom.Atom) func(n *html.Node) bool {
}

var WithBody = WithAtom(atom.Body)

// func filternodes(n *html.Node, cond func(*html.Node) bool, yield func(*html.Node) bool) bool {
// for c := range ChildNodes(n) {
// if !cond(c) {
// continue
// }
// if !yield(c) {
// return false
// }
// if !filternodes(c, cond, yield) {
// return false
// }
// }
// return true
// }

// // Filter returns a sequence yielding child nodes of n where cond is true.
// // If cond is false for a node, Filter does not yield any of its children.
// func Filter(n *html.Node, cond func(*html.Node) bool) iter.Seq[*html.Node] {
// return func(yield func(*html.Node) bool) {
// filternodes(n, cond, yield)
// }
// }
Loading

0 comments on commit a8107af

Please sign in to comment.