Closed gabyx closed 3 years ago
This is a good idea, but poses some problems. Lua, by default does not include the tools to deal with path modifications. Paths are platform dependent, with path separators \
on Windows and /
on Linux and Mac. There are two possibilities to support path modifying functions such as dirname
or is_relative
:
Neither is especially difficult, but both options require more work than I'm willing/able to invest right now.
Patches would be most welcome.
I can certainly do a PR. What do you mean with pure Lua? Isn’t there a std lib for path modifications? The path handling library by pandoc is haskell, right? With a python filter this would be really easy to acomplish, but I dont know about the walk_****
functions...
Great!
Lua aims to run on any platform that can be targeted with ANSI C. The latter has no concept of paths, so neither has Lua. Path libraries for Lua exist, but are all written in C, and thereby not an option. The necessary path manipulations should still be doable by pure string manipulations.
The path library used in pandoc is filepath. If you are interested in how this can be exposed to Lua, check hslua-module-system, which exposes selected system and file related functions. Exposing filepath would best be done by adding the necessary bindings to that package.
Probably these functions are the only ones which give enough access to do almost if not all path handling issues in filters:
Any help and review is kindly welcome. I will try next week what I can do, I think I can directly build and test the hslua module.
What would be the next step to test a merged PR: https://github.com/hslua/hslua-module-system/pull/1 with this include-filter. How to we get these changes here?
Can we just version check the pandoc version in the include-files filter (is it possible?), such that we error out if somebody use a older pandoc version with no lua file manipulations functions...?
Got it: :-) See https://github.com/jgm/pandoc/pull/6565
@gabyx I think latest changes to include-files will solve this issue. Please check.
@lmunch Thats really greate to hear: Is the doc already up to date, because I ve not seen any explanation on the feature?
@gabyx See the Recursive transclusion section. It's default behaviour now, so no feature flag.
@lmunch : Thanks for the effort! Its great! Sorry I was to impatient to read carefully!
Resolved with #173
Would it make sense to add an attribute
relative-to-current-dir=true
or something such that, all paths or better all relative paths are resolved to the current file path we are currently at (maybe not so easy to distinguish platform independent, relative vs absolute paths). Therefore maybe, just replace a variable "${current-dir}/b/c.md" in all paths, which would give a deterministic and consistent way of relative imports :)?@tarleb: What do you think?
In
a/b.md
or In
a/b.md