pelican icon indicating copy to clipboard operation
pelican copied to clipboard

Add support for compound file extensions.

Open holden-nelson opened this issue 4 years ago • 5 comments

Created a new class ReaderTree that is an infinitely nested defaultdict containing components of the extension. See comments on PR #2816.

Pull Request Checklist

Resolves: #issue-number-here

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

holden-nelson avatar Jan 07 '22 23:01 holden-nelson

I'll go over it in more detail when I have more time but glanced over it briefly and this looks promising, thank you :). I think Generators._include_file also needs some adjustment to support compound extensions. Otherwise I don't think it would include foo.bar.baz even if there was a reader for bar.baz. Building on the endswith idea, this might do the trick:

if extensions is False or basename.endswith(extensions):
    return True

avaris avatar Jan 08 '22 00:01 avaris

Mmh. Right. Forgot about __include_file. I see how that would work. I'll edit my PR.

holden-nelson avatar Jan 08 '22 01:01 holden-nelson

Edited.

holden-nelson avatar Jan 12 '22 00:01 holden-nelson

Hello,

Poking around the source code I believe there is another location that is affected by this change.

In the contents.py file, the __init__ method of the Content class generates a slug. If the SLUGIFY_SOURCE is set to basename it uses everything to the left of the last dot to create the slug. So for a file ending in .md.html the .md will be passed into the slugify function.

Additionally, the SourceFileGenerator class grabs the basename of the source files in the same way.

Should I continue working on my PR and write code to account for these issues?

holden-nelson avatar Mar 14 '22 17:03 holden-nelson

Also pushed a small change that should fix the linter failing :)

holden-nelson avatar Mar 14 '22 17:03 holden-nelson