orbikm / mkdocs-ezlinks-plugin

Plugin for mkdocs which enables easier linking between pages
MIT License
34 stars 17 forks source link

"scanners" folder, pugin configuration, files other than markdown and links starting with "https://" #12

Closed AlphaJack closed 3 years ago

AlphaJack commented 3 years ago

Hi, I was trying to use your plugin but I encountered some issues:

Scanners

python setup.py install in my case did not copy the "scanners" folder to the package folder (/usr/lib/python3.9/site-packages/mkdocs_ezlinks_plugin/), and I had to do it manually. Is this desired?

Plugin configuration

In my mkdocs.yml, the following

    - ezlinks:
        - wikilinks: {true|false}

throwed ERROR - Config value: 'plugins'. Error: Invalid config options for the "ezlinks" plugin., so I guess it should be:

    - ezlinks:
        wikilinks: {true|false}

Files other than markdown

I am getting a bunch of

WARNING -  Duplicate filename `KaTeX_Size3-Regular` detected. Linking to it will only match the first file.
WARNING -  Duplicate filename `KaTeX_Size3-Regular` detected. Linking to it will only match the first file.
WARNING -  Duplicate filename `KaTeX_Size4-Regular` detected. Linking to it will only match the first file.
WARNING -  Duplicate filename `KaTeX_Size4-Regular` detected. Linking to it will only match the first file.
WARNING -  Duplicate filename `katex` detected. Linking to it will only match the first file.
# [ ... ]

I also have references to many "index.md" files, but I never entered them in square brackets. KaTeX source files for instance are css files with multiple lines like this:

src: url(fonts/KaTeX_Size3-Regular.woff2) format('woff2'), url(fonts/KaTeX_Size3-Regular.woff) format('woff'), url(fonts/KaTeX_Size3-Regular.ttf) format('truetype');

Should the plugin ignore non markdown files/link format?

HTTP links

I am also getting a bunch of

WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://www.mkdocs.org' in file map.
WARNING -  Did not find 'https://example.org' in file map.
WARNING -  Did not find 'https://example.com' in file map.
# [...]

Should the plugin ignore URLs starting with "http://" or "https://"?

orbikm commented 3 years ago

Hello @AlphaJack,

Thank you for using my plugin, and especially for taking the time to submit these issues! I've made a number of changes based on your experiences, and detail them below.

Scanners

This is absolutely unintended. Have fixed in a0dc11b.

Plugin Configuration

You're correct, this is a typo in the README.md, I've addressed that in e68fd15

Files other than markdown

I don't want to ignore files that are not markdown, as a user may still want to link to other types of files, such as images, documents, zip files, etc. The warning in question is simply over alerting on something that's not inherently an issue.

Those warnings are being generated during the generation of the file lookup table, so it doesn't matter if there is a link to the file or not, it was warning whenever a duplicate filename would lead to a collision in the case that it was linked to by filename.

I think a regular user is unlikely to care about this duplication, as it's more related to an implementation detail than anything else. I've downgraded this message to a debug level message, which you can always see by passing the --verbose flag to mkdocs.

HTTP Links

Should the plugin ignore URLs starting with "http://" or "https://"?

Yup :smile:. I've addressed this in a0dc11b

I will be putting together a release based on these changes shortly.

orbikm commented 3 years ago

I've published this as mkdocs-ezlinks-plugin==0.1.6, and will close this as resolved. If you still experience any of these issues, or have further questions feel free to reopen / comment as needed.

AlphaJack commented 3 years ago

I don't want to ignore files that are not markdown

Yes, I meant ignoring links in files that are inside markdown files, as I was thinking that the plugin parsed even links as src: url(fonts/KaTeX_Size3-Regular.woff2).

So what it does is just generating a filelist and warning about possible duplicates that would be ignored if linked?


EDIT: I took some time to package the plugin for the AUR, hopefully it will reach even more people there

orbikm commented 3 years ago

So what it does is just generating a filelist and warning about possible duplicates that would be ignored if linked?

Yes, that is precisely what it was doing. Even if it would have scanned the contents of those files, the regex for EZLinks would not capture a link like url(...). It explicitly searches for [text](text "text") or [[text#text|text]] type links.

I have downgraded those messages to debug level instead of warning, to allow sites with duplicate filenames to build in strict mode.

Thanks for submitting to the AUR. I do not use Archlinux myself, so I'm not familiar with that repository.