Skip to content

fix: default-extension not applied to local files, and tweak help - #2245

Merged
mre merged 10 commits into
lycheeverse:masterfrom
rsc-s:fix-default-exte
Jun 29, 2026
Merged

mre merged 10 commits into
lycheeverse:masterfrom
rsc-s:fix-default-exte

Conversation

@katrinafyi

Copy link
Copy Markdown
Member

This implementation is not the best because any plaintext file is changed to the default extension, but a file could genuinely be a plaintext file. To do this properly would need something like a TryFrom for FileType, but this conflicts with the From which is heavily used. It's probably not a big deal right now because the HTML and markdown extractors also perform plaintext extraction.

Also tries to improve the CLI help text based on suggestions in issue.

Fixes #2244

it's not the best because any plaintext file is changed to the default
extension, but a file could genuinely be a plaintext file. to do this
properly would need something like a TryFrom for FileType, but this
conflicts with the From.

it's probably not a big deal right now because the HTML and markdown
extractors also perform plaintext extraction.
previously was passing spuriously because both the assertion only
looked for an absolute URL which is detected even in plaintext mode.

@mre mre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. one minor comment

Comment thread benches/src/extract.rs
Comment thread lychee-lib/src/types/input/input.rs Outdated
…n file extension."

This affects how links are extracted from certain input sources. This
is useful for stdin inputs, files without extensions, and files with
unknown extensions.

Examples:
  --default-extension md
  --default-extension html

To automatically append file extensions when locating files, see
`--fallback-extensions`.
@katrinafyi

Copy link
Copy Markdown
Member Author

In the latest changes, I've also changed the text a bit. It was surprisingly hard to write an unambiguous leading sentence for the option description. This is what I came up with, let me know if it's okay. also @nobkd wdyt :)

  --default-extension <EXTENSION>
      Parse input sources without a recognised file type by using the given
      file extension.

      This affects how links are extracted from certain input sources. This
      is useful for stdin inputs, files without extensions, and files with
      unknown extensions.

      Examples:
        --default-extension md
        --default-extension html

      To automatically append file extensions when locating files, see
      `--fallback-extensions`.

@nobkd

nobkd commented Jun 29, 2026

Copy link
Copy Markdown

That sounds quite nice! Thanks for taking this on :)

@mre mre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks. 😊

@mre
mre merged commit 3d6c1b6 into lycheeverse:master Jun 29, 2026
7 checks passed
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.

--default-extension is not extracting links without URL-scheme

3 participants