pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
600 stars 165 forks source link

`include-files` relative path for top-level file not in root #269

Open ricopicone opened 1 year ago

ricopicone commented 1 year ago

If I pandoc with the include-files filter a document in a subdirectory of the root ./sub/a.md that includes a relative file path, say

```include
subsub/b.md
where `b.md` has path `./sub/subsub/b.md`, the filter cannot find the file. It works if I use the path relative to the root, i.e.,
````markdown
```include
sub/subsub/b.md


This is a problem for me because I want to include `a.md` in multiple documents that don't share the same root.

I think there are two solutions:

1. include an option to turn off relative paths in includes (my preference) or
2. change the behavior for a top-level file `./sub/a.md` (i.e., the one passed to `pandoc`) such that its includes are relative to its directory, `./sub`.

I don't want to break existing code, so I think having an option to turn off all relative includes is probably best. I haven't tried editing the filter because I'm hoping others have input (or a solution!) for this. Thanks!
ricopicone commented 1 year ago

I think a workaround is to add a wrapper file to the root directory. However, this is pretty hacky.