summaryrefslogtreecommitdiff
path: root/kew.go
diff options
context:
space:
mode:
authoruint <abhinav.prsai@gmail.com>2025-12-19 21:16:06 +0000
committeruint <abhinav.prsai@gmail.com>2025-12-19 21:16:06 +0000
commit38fe6ae08de124d6d96e066569add8861c2cec9c (patch)
tree946295bb06bb028890dbe9808b622b33e3c753c8 /kew.go
parent49ccde2afee4ac77a4cbeef9db5264e8059c6afe (diff)
allow references to other MD files
just replace the suffix
Diffstat (limited to 'kew.go')
-rw-r--r--kew.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/kew.go b/kew.go
index f84480e..1b923c7 100644
--- a/kew.go
+++ b/kew.go
@@ -88,6 +88,21 @@ func copy_file(src string, dst string) error {
return err
}
+func fix_md_references(s string) string {
+ r := strings.NewReplacer(
+ /* common cases */
+ ".md)", ".html)",
+ ".md\"", ".html\"",
+ ".md'", ".html'",
+ ".md)", ".html)",
+ ".md#", ".html#",
+ ".md>", ".html>",
+ ".md ", ".html ",
+ ".md,", ".html,",
+ )
+ return r.Replace(s)
+}
+
func markdown_to_html(path string) (string, error) {
cmd := exec.Command("lowdown", "-Thtml")
@@ -192,6 +207,7 @@ func main() {
if err != nil {
return err
}
+ html = fix_md_references(html)
relhtml := strings.TrimSuffix(rel, ".md") + ".html"
cur := relhtml