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

Handle internal links without extensions #3384

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dltj
Copy link

@dltj dltj commented Jul 28, 2024

Pull Request Checklist

  • Ensured tests pass and (if applicable) updated functional test output
  • Conformed to code style guidelines by running appropriate linting tools
  • Added tests for changed code
  • Updated documentation for changed code

Reason for change

Jekyll—or at least Jekyll as I've configured it—allows for internal links to files regardless of their extension. Say, for example, you have two posts: post1.md and post2.html

Title: Post 1

This file has an internal link to post 2: [Link to Post 2]({filename}/post2)

I could convert-and-rename post2.html to post2.md and the internal link in post1.md would not need to change. (I did this a lot in my Jekyll days because the Jekyll blog had a lot of content exported from WordPerfect as HTML files.)

Proposed implementation

In _link_replacer(), create a loop of Reader filename extensions to append to the end of the file path and calls _get_linked_content() with that extension. The first time through the loop the extension is None so the function behaves as it currently does. If that fails to find a path in the context, the loop tries adding extensions to the path.

Open questions

  1. How does one get a list of extensions? I could import them through, say, YAMLMetadataReader.file_extensions, but that seems like an unwise coupling.

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.

1 participant