Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot #+INCLUDE files usign relative paths #26

Closed
semente opened this issue Feb 21, 2021 · 5 comments · Fixed by #35
Closed

Cannot #+INCLUDE files usign relative paths #26

semente opened this issue Feb 21, 2021 · 5 comments · Fixed by #35
Labels
bug Something isn't working org-mode

Comments

@semente
Copy link
Contributor

semente commented Feb 21, 2021

Considering the route below:

(weblorg-route
 :name "posts"
 :input-pattern "posts/*.org"
 :template "post.html"
 :output ".build/posts/{{ slug }}.html"
 :url "/posts/{{ slug }}.html")

And the files posts/post.org and posts/example.txt:

# post.org
#+INCLUDE: "example.txt"
# example.txt
Lorem ipsum...

I get an error when publishing the website:

Cannot include file /home/semente/pub/example.txt

To make this work I have to use #+INCLUDE: "posts/example.txt", which is not a big deal but I believe this is a bug. Perhaps the function that generates the HTML isn't switching to the directory of the file so it won't have the right context.

@semente semente changed the title Cannot #+INCLUDE files usign relative paths Cannot #+INCLUDE files usign relative paths Feb 21, 2021
@clarete clarete added the bug Something isn't working label Feb 21, 2021
@mrmechko
Copy link
Contributor

To expand on this, I would like to collect org-mode files that exist in other folders and export them in my weblorg instance.

The above workaround doesn't suffice when trying to render files included from another :base-dir

Say I have a folder called ~/docs/141 and a subfolder, ~/docs/141/sections/. If I set a weblorg-route that points to ~/docs/141/ the files render correctly but any #+INCLUDE: directives pointing to ~/docs/141/sections fail.

@mrmechko
Copy link
Contributor

I can't quite figure out how to do it myself, but at line 942 in weblorg--parse-org-file if there was an org-to-org export, it would handle the includes, right? I'll try and figure it out next time I sit down with this.

@clarete
Copy link
Collaborator

clarete commented Feb 26, 2021

Hi hi @mrmechko! that's right! you're definitely on the right path. I don't know if that's the cleanest, but I was thinking about solving this problem by saving the current directory in a local variable, cd'ing to the path where the Org file is located (dirname of input-path which is the only parameter for weblorg--parse-org-file) and then cd'ing back to the original path once the parsing is done! It'd be awesome if you wanted to take a stab at fixing this issue! <o/

@mrmechko
Copy link
Contributor

Turns out you can change the file that a buffer points to! Once you got that, a simple org-to-org export into your temp buffer, and boom, the rest of weblorg handles everything.

This means I can set up routes for my various documents which are part of their own respective git repos and then generate a single webpage in my weblorg directory.

@clarete
Copy link
Collaborator

clarete commented Mar 3, 2021

Thanks to @mrmechko's PR in #35, this issue should be fixed now! Please feel free top re-open it or to open a new one if you find anything weird in there 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working org-mode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants