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

Relative links aren't detected from STDIN or local files #671

Open
nacnudus opened this issue Jul 1, 2022 · 2 comments
Open

Relative links aren't detected from STDIN or local files #671

nacnudus opened this issue Jul 1, 2022 · 2 comments
Labels

Comments

@nacnudus
Copy link

nacnudus commented Jul 1, 2022

A similar issue was reported in #183 and addressed by #217. However, this doesn't work when files are passed into STDIN, or for local files.

lychee --dump --base https://www.example.com example.html # works
lychee --dump --base https://www.example.com example # doesn't work
cat example.html | lychee --dump --base https://www.example.com # doesn't work

Could this be fixed by having --base force HTML mode?

@mre
Copy link
Member

mre commented Jul 1, 2022

That's a tricky one.
I thought about assuming html input if --base was a valid URL, but Markdown files can also contain relative links and be prefixed with a URL. So that alone is not a decision criteria.

lychee has an internal file-type hint, that we could expose on the CLI, even though it sounds like a workaround.

/// Lychee Input with optional file hint for parsing
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Input {
/// Origin of input
pub source: InputSource,
/// Hint to indicate which extractor to use
pub file_type_hint: Option<FileType>,
/// Excluded paths that will be skipped when reading content
pub excluded_paths: Option<Vec<PathBuf>>,
}

I'm open for suggestions on how to make the file type explicit in an ergonomic way. Alternatively maybe I'm overlooking a possibility to make it work without any file type hints.

@mre mre added enhancement New feature or request request-for-comments labels Jul 1, 2022
nacnudus added a commit to nacnudus/lychee that referenced this issue Jul 1, 2022
This is an attempt to address lycheeverse#671 by adding a flag `--html` to parse
the input as HTML.  Otherwise, STDIN and local files without the `.html`
suffix are parsed as plain text.
@nacnudus
Copy link
Author

nacnudus commented Jul 1, 2022

Thank you for responding so quickly. I've attempted to address this issue in #673.

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

No branches or pull requests

2 participants