2021-07-17 06:26:40 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-07-17 07:51:06 +03:00
|
|
|
"flag"
|
2021-11-21 09:44:10 +03:00
|
|
|
wikilink "github.com/abhinav/goldmark-wikilink"
|
|
|
|
"github.com/yuin/goldmark"
|
2021-07-17 06:26:40 +03:00
|
|
|
)
|
|
|
|
|
2021-11-21 09:44:10 +03:00
|
|
|
var md goldmark.Markdown
|
2021-12-28 00:19:05 +03:00
|
|
|
|
2021-11-21 09:44:10 +03:00
|
|
|
func init() {
|
|
|
|
md = goldmark.New(
|
|
|
|
goldmark.WithExtensions(&wikilink.Extender{}),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-07-17 06:26:40 +03:00
|
|
|
type Link struct {
|
|
|
|
Source string
|
|
|
|
Target string
|
|
|
|
Text string
|
|
|
|
}
|
|
|
|
|
2021-07-17 07:01:08 +03:00
|
|
|
type LinkTable = map[string][]Link
|
|
|
|
type Index struct {
|
2021-12-28 00:19:05 +03:00
|
|
|
Links LinkTable
|
2021-07-17 07:01:08 +03:00
|
|
|
Backlinks LinkTable
|
|
|
|
}
|
|
|
|
|
2021-08-25 20:05:12 +03:00
|
|
|
type Content struct {
|
2021-12-28 00:19:05 +03:00
|
|
|
Title string
|
2021-08-25 20:05:12 +03:00
|
|
|
Content string
|
|
|
|
}
|
|
|
|
|
|
|
|
type ContentIndex = map[string]Content
|
|
|
|
|
2021-12-28 00:19:05 +03:00
|
|
|
type IgnoredFiles struct {
|
2021-07-18 18:50:13 +03:00
|
|
|
|
2021-07-18 23:30:37 +03:00
|
|
|
}
|
|
|
|
|
2021-12-28 00:19:05 +03:00
|
|
|
func getIgnoredFiles() {
|
2021-08-25 20:05:12 +03:00
|
|
|
|
2021-07-17 07:38:12 +03:00
|
|
|
}
|
|
|
|
|
2021-07-17 06:26:40 +03:00
|
|
|
func main() {
|
2021-07-17 07:51:06 +03:00
|
|
|
in := flag.String("input", ".", "Input Directory")
|
|
|
|
out := flag.String("output", ".", "Output Directory")
|
2021-08-25 20:05:12 +03:00
|
|
|
index := flag.Bool("index", false, "Whether to index the content")
|
2021-07-17 07:51:06 +03:00
|
|
|
flag.Parse()
|
2021-08-25 20:05:12 +03:00
|
|
|
l, i := walk(*in, ".md", *index)
|
2021-07-17 07:38:12 +03:00
|
|
|
f := filter(l)
|
2021-08-25 20:05:12 +03:00
|
|
|
err := write(f, i, *index, *out)
|
2021-07-17 07:38:12 +03:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-07-17 06:26:40 +03:00
|
|
|
}
|