~kaction/fix-links

f53a219e98b7cf0d5b84a3272d6902c1ef5ecb37 — Dmitry Bogatov 5 months ago fc80a2c master
Add command line flag for processing root
1 files changed, 8 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +8 -1
@@ 1,6 1,7 @@
package main

import (
	"flag"
	"fmt"
	"golang.org/x/net/html"
	"golang.org/x/net/html/atom"


@@ 11,6 12,13 @@ import (
	"strings"
)

var start string

func init() {
	flag.StringVar(&start, "root", ".", "directory containing html files")
	flag.Parse()
}

func fixNode(s fs.FS, n *html.Node, fixed *bool) {
	if n.Type != html.ElementNode || n.DataAtom != atom.A {
		goto recurse


@@ 48,7 56,6 @@ recurse:
}

func main() {
	start := "."
	here := os.DirFS(start)

	err := fs.WalkDir(here, ".", func(p string, d fs.DirEntry, err error) error {