-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Bad include #6322
Comments
@cup You're an Org mode user too (I have seen you in the Nim community too)! :) Copying @niklasfasching on this issue as he's the maintainer of go-org. |
@kaushalmodi, yeah. The only problem with Org mode, is syntax highlighting is https://github.com/cup/rosso/blob/master/publish/markup.md#org-mode However I think Hugo has its own highlighter, so if I can resolve this issue |
I'm a bit confused.. the issue here is with just highlighting? I think that the real issue here is parsing of Org mode Hugo does do highlighting of Org syntax, but that's a different thing than parsing, and that gets done by Chroma. |
As asked in the other ticket, could you give some more information on what exactly the issue is? |
@niklasfasching while it might work as expected when invoking So likely Hugo is breaking the path before being passed to go-org. |
go-org uses the DocumentName to get a base path for resolving includes. It looks like hugo passes a relative path as |
The problem here is that the path in I'm currently working around this by symlinking |
I seem to get the correct behaviour if I compile my own hugo with this very hacky change: diff --git a/helpers/content.go b/helpers/content.go
index f6576c04..9dce57fc 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -22,6 +22,7 @@ import (
"fmt"
"html/template"
"os/exec"
+ "path/filepath"
"runtime"
"unicode"
"unicode/utf8"
@@ -762,7 +763,12 @@ func orgRender(ctx *RenderingContext, c ContentSpec) []byte {
return highlightedSource
}
- html, err := config.Parse(bytes.NewReader(ctx.Content), ctx.DocumentName).Write(writer)
+ contentDir := ctx.Cfg.GetString("contentDir")
+ if contentDir == "" {
+ contentDir = "content"
+ }
+ docpath := filepath.Join(contentDir, ctx.DocumentName)
+ html, err := config.Parse(bytes.NewReader(ctx.Content), docpath).Write(writer)
if err != nil {
jww.ERROR.Printf("Could not render org: %s. Using unrendered content.", err)
return ctx.Content There's almost certainly a much cleaner way to do it, but I'm not sufficiently familiar with hugo's code to find it, unfortunately. |
Here is where the hugo/hugolib/page__per_output.go Lines 313 to 319 in 13768c3
As seen in the above code, |
Includes of content directory files are fixed in master / the next release - @cup your example should work now.. We could look into supporting includes from other directories as well, this just fixes the most common use-case. |
@niklasfasching I ended up just writing a shortcode:
https://github.com/cup/autumn/blob/master/layouts/shortcodes/read.html so I am using that with MarkDown. At any rate, Thanks for your work |
Thx! Cool, so this can be closed? |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Using this file:
I get this result:
Using this file:
I get this result:
The text was updated successfully, but these errors were encountered: