kovetskiy / mark

Sync your markdown files with Confluence pages.
https://samizdat.dev
Other
978 stars 143 forks source link

feat: Add fallback directory to load includes from #375

Closed mrueg closed 9 months ago

mrueg commented 9 months ago

This is a more flexible solution than https://github.com/kovetskiy/mark/pull/355 and allows users to set custom include paths as a fallback.

@Skeeve please take a look and let me know if this works for you as well. You should be able to use it via --include-path "~/config/mark.d" or similar.

Skeeve commented 9 months ago

Without testing: Fine for me. I assume you can set the path in the mark-file.

Skeeve commented 9 months ago

Fails for me.

When I put my include file into the current directory, it works.

When I have it in another directory, set via include-path in the mark file, I get this runtime exception:

2023-10-17 22:26:08.315 INFO  processing testauto.md
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1402a4c]

goroutine 1 [running]:
text/template.(*Template).Lookup(0xc0003cc3c0?, {0xc0003cc3c0?, 0x0?})
        /usr/local/go/src/text/template/template.go:189 +0x2c
github.com/kovetskiy/mark/pkg/mark/includes.LoadTemplate({0xc0001b5000, 0x33}, {0xc0003cc3c0, 0xd}, {0x0, 0x0}, {0x0, 0x0}, 0x0)
        /go/src/github.com/kovetskiy/mark/pkg/mark/includes/templates.go:41 +0x218
github.com/kovetskiy/mark/pkg/mark/includes.ProcessIncludes.func2({0xc000184368?, 0x8?, 0x0?})
        /go/src/github.com/kovetskiy/mark/pkg/mark/includes/templates.go:149 +0x6a5
github.com/kovetskiy/mark/pkg/mark/includes.ProcessIncludes.(*Regexp).ReplaceAllFunc.func3({0xc0003cc3a8, 0x1, 0x8}, {0xc0003cc3b0?, 0x0?, 0x0?})
        /usr/local/go/src/regexp/regexp.go:707 +0x8c
regexp.(*Regexp).replaceAll(0xc0002925a0, {0xc000184367, 0x4a, 0x59}, {0x0, 0x0}, 0x2, 0xc0003bf608)
        /usr/local/go/src/regexp/regexp.go:642 +0x3e5
regexp.(*Regexp).ReplaceAllFunc(...)
        /usr/local/go/src/regexp/regexp.go:706
github.com/kovetskiy/mark/pkg/mark/includes.ProcessIncludes({0x1bbb870?, 0x17cd50e?}, {0xc0001b5000?, 0x7ff7bfeff4c7?}, {0xc000184367?, 0x1?, 0xc0003cada0?}, 0x0)
        /go/src/github.com/kovetskiy/mark/pkg/mark/includes/templates.go:106 +0x13c
main.processFile({0x7ff7bfeff4e4, 0xb}, 0x17760c0?, 0x0?, {0x0?, 0x0}, {0xc00029f880, 0x7})
        github.com/kovetskiy/mark/main.go:347 +0x589
main.RunMark(0xc000284940)
        github.com/kovetskiy/mark/main.go:273 +0x6fe
github.com/urfave/cli/v2.(*Command).Run(0xc0002c2420, 0xc000284940, {0xc0001a6120, 0x6, 0x6})
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/command.go:274 +0x998
github.com/urfave/cli/v2.(*App).RunContext(0xc000326000, {0x1bc7680?, 0x2097440}, {0xc0001a6120, 0x6, 0x6})
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/app.go:332 +0x5b7
github.com/urfave/cli/v2.(*App).Run(...)
        /go/pkg/mod/github.com/urfave/cli/v2@v2.25.7/app.go:309
main.main()
        github.com/kovetskiy/mark/main.go:211 +0x186