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

Add org-mode support for internal links (incl. update documentation) #322

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dalanicolai
Copy link

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.

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
@@ -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.
Copy link
Member

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.

Copy link
Author

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

(defun org-custom-internal-link-url-export (path desc format)
(cond
((eq format 'html)
(format "<a href=\"%s/index.html\">\"%s\"" path desc))))
Copy link
Member

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.

Copy link
Author

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

v8/orgmode/README.md Outdated Show resolved Hide resolved
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)
@dalanicolai
Copy link
Author

I have implemented your suggestions/requirements for accepting the pull request

@Kwpolska
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants