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 support for user-defined processing of links #720

Open
krisbalintona opened this issue Jul 20, 2023 · 2 comments
Open

Add support for user-defined processing of links #720

krisbalintona opened this issue Jul 20, 2023 · 2 comments

Comments

@krisbalintona
Copy link

Would it be reasonable to allow users to create their own functions to transform org link types into markdown links? For instance, if the user (or a package that the user uses) creates their own org link type, this feature would allow the user to control what ox-hugo does with the link.

In my case, I use Denote. Denote defines denote links, which are links between denote files. I use a per-file workflow and would like denote links between org files (which are exported as pages to my site) to be exported as relative web page links on the site. Right now, I do this by overriding org-hugo-link and handling denote links specially.

Taking a look at org-hugo-link, I think it would be possible to iterate through user-defined functions that take type and raw-path as arguments and returns the link (as a string). This would be similar to org-hugo-tag-processing-functions; we can call this proposed, user-exposed variable org-hugo-link-processing-functions. If I'm not mistaken, this could be done at the beginning of the cond in org-hugo-link, prior to org-hugo's default processing.

This feature gives the user flexibility for interpreting their own link types as well as existing link types, meaning users do not have to override the entire function in order to change how one type of link is transformed. Take my use case described above: I can simply convert my existing code into a function and add it to org-hugo-link-processing-functions. Finally, this proposed feature will not affect existing configurations.

If this sounds appealing, I can go ahead and draft a pull request for it.

@justinabrahms
Copy link

I'm not a maintainer, but this is appealing. I came here looking exactly for this functionality. Even a copy of what you're doing with org-hugo-link would be nice.

@einsiedlerspiel
Copy link

You can do this by defining an export handler for the link type in question with org-link-set-parameters.

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

No branches or pull requests

3 participants