-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add org-mode support for internal links (incl. update documentation) #322
base: master
Are you sure you want to change the base?
Conversation
The internal link in ox-html is a little fuzzy. For example, [[./test.org][test]] will be generated as <a href="file:///./test.jpg">"test" because the path is considered as an absolute file path. In order to correctly generate internal link urls, you may write [[int-url:./test][test], JUST THE FILENAME WITHOUT THE .org EXTENSION PART and then it should be generated as <a href="./test/index.html">"test". This is just a slightly adapted copy if the img-url solution for image url's
v8/orgmode/README.md
Outdated
@@ -44,3 +44,7 @@ because the path is considered as an absolute file path. | |||
|
|||
In order to correctly generate image urls, you may write `[[img-url:/images/test.jpg]]`, | |||
and then it should be generated as `<img src="/images/test.jpg" alt="test.jpg">`. | |||
|
|||
The internal link in ox-html is a little fuzzy. For example, `[[./test.org][test]]` will be generated as `<a href="file:///./test.jpg">"test"` because the path is considered as an absolute file path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think you meant .jpg
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed forgot to change that one... I was tired after studying how it all worked
v8/orgmode/init.el
Outdated
(defun org-custom-internal-link-url-export (path desc format) | ||
(cond | ||
((eq format 'html) | ||
(format "<a href=\"%s/index.html\">\"%s\"" path desc)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t include index.html
in those links. It’s not necessary, and we allow changing the filename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah thanks didn't know that. just starting with nikola
1. Change link prefix from 'int-url' to 'internal'. 2. Replace 'path' with a substring method that removes the .org extension in from the original org source file syntax to make the 'internal link' export function work similar as the 'img-url' export function, and also to keep the differences between a nikola org source file minimal with the original org source file.
update link prefix from 'int-url' to 'internal'. Remove reuirement to leave out .org extension in link (this is removed by a substring method in the init.el file)
I have implemented your suggestions/requirements for accepting the pull request |
I don’t know anything about org-mode, but could you show a more specific case where this style of linking would actually be useful? Can’t you just use links like 'foo.jpg' and get the correct output? And as for the part with .org specifically, why would you want to use that? |
Similar to the problem with image url's, the url's of internal link are also not handled well by ox-html for correct use with nikola. I copied and slightly the solution for handling image urls so that internal urls will also be handled correctly now with org-mode.
In addition to changing the implementing the code I updated the documentation in the README file for the plugin.