Skip to content

Improve wikilink parsing and checking#1799

Merged
thomas-zahner merged 27 commits intolycheeverse:masterfrom
JayJayArr:1788-spaced-wikilinks
Dec 23, 2025
Merged

Improve wikilink parsing and checking#1799
thomas-zahner merged 27 commits intolycheeverse:masterfrom
JayJayArr:1788-spaced-wikilinks

Conversation

@JayJayArr
Copy link
Contributor

@JayJayArr JayJayArr commented Aug 14, 2025

  • Extract the correct filename from a Wikilink by removing potholes and fragments
  • Create a new Checker for wikilinks, make it clear to the users that a base-url is required
    • Check Obsidian style wikilinks without headers
    • strip fragments & potholes from wikilinks
    • traverse the wiki-directory and check if any of the Filenames exist with any of the specified --fallback-extensions

@JayJayArr JayJayArr changed the title Improve wikilinks, change to opt-in Improve wikilink parsing and checking Aug 18, 2025
@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch from e9983af to f6f7814 Compare August 21, 2025 06:03
@JayJayArr
Copy link
Contributor Author

@jrfnl I am having trouble understanding the MediaWiki links with () and :.
Are there really markdown files named Help:Links or where do they point to?
Is [[Extension:DynamicPageList (Wikimedia)]] different to [[Extension:DynamicPageList]]

Could you please clarify this?

@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch 3 times, most recently from ec15bc2 to 3a919db Compare September 30, 2025 10:24
@JayJayArr JayJayArr marked this pull request as ready for review September 30, 2025 12:28
@mre
Copy link
Member

mre commented Sep 30, 2025

Guess you can rebase on top of master now to fix CI.

Copy link
Member

@mre mre left a comment

Choose a reason for hiding this comment

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

Good work! I've added a bunch of comments, but don't worry.
Most of them are about very minor paper cuts. Most of it can be fixed pretty easily by clicking on the "accept suggestion" button, I hope. 😉

@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch 2 times, most recently from b251e14 to f6303a9 Compare October 3, 2025 17:10
@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch 3 times, most recently from c6c566f to 589e1f3 Compare October 13, 2025 12:45
@thomas-zahner thomas-zahner force-pushed the master branch 2 times, most recently from fcdf77c to e0912ab Compare October 21, 2025 12:53
@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch from 8f60582 to 589e1f3 Compare October 22, 2025 21:08
@mre
Copy link
Member

mre commented Nov 12, 2025

@JayJayArr, any chance you could fix the merge conflicts? I would love to get this great work merged. 😊

@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch 2 times, most recently from a016b0a to 341e27f Compare November 13, 2025 20:59
@JayJayArr
Copy link
Contributor Author

There we go. Lets call it okay for now 😅

@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch 2 times, most recently from acc307b to 3dd860b Compare November 20, 2025 23:44
@JayJayArr
Copy link
Contributor Author

Apparently archive.org has some problems right now which breaks CI

@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch from 3dd860b to 1af4670 Compare November 23, 2025 07:50
@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch from ab73e52 to 0ffc42e Compare December 22, 2025 16:31
@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch from 0ffc42e to dfeab26 Compare December 22, 2025 16:36
@JayJayArr
Copy link
Contributor Author

Thanks for taking a look at the error handling here @thomas-zahner !
Added some more testcases for valid and invalid WikiLinks, if you still have any specific testcase in mind that we should check here please let me know. Added a check for unsupported characters as well 😅

Copy link
Member

@thomas-zahner thomas-zahner left a comment

Choose a reason for hiding this comment

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

Thank you for the additions. We're almost ready to merge. Apart from the review comments I still don't see any tests which check for invalid wikilinks. Maybe I've missed it?

Could you add a test which results in a WikilinkNotFound error. This path seems to be untested as of now.

@JayJayArr JayJayArr force-pushed the 1788-spaced-wikilinks branch 2 times, most recently from 273e1d8 to b1d0fee Compare December 23, 2025 15:22
@JayJayArr
Copy link
Contributor Author

Added a Test from the cli and a Unit Test for the WikilinkResolver for this case. You did not miss it, it was indeed missing, sorry for the gap there!

fix typo

fix typo
@thomas-zahner thomas-zahner merged commit d530f1f into lycheeverse:master Dec 23, 2025
7 checks passed
@thomas-zahner
Copy link
Member

thomas-zahner commented Dec 23, 2025

@JayJayArr Thank you very much for the changes and the work, this really is a great addition. I've just removed a dbg! expression you probably forgot to remove and simplified indexing with 0c3dcb5.

@mre mre mentioned this pull request Dec 23, 2025
@jrfnl
Copy link

jrfnl commented Dec 23, 2025

@JayJayArr and everyone who reviewed and contributed to the discussion: thank you for working on this! I look forward to seeing this in the next release. 💞

@JayJayArr
Copy link
Contributor Author

Thanks to both of you @mre & @thomas-zahner for your support on this!

@JayJayArr JayJayArr deleted the 1788-spaced-wikilinks branch December 24, 2025 10:51
@katrinafyi
Copy link
Member

katrinafyi commented Dec 27, 2025

I was trying out this feature and I wrote these notes about things that I thought were unexpected:

  • when a link is not found, the error message is long because it repeats the message twice. it also repeats the base directory twice and makes the invalid path /home/x/progs/lychee/fixtures/home/x/progs/lychee/fixtures/Doesn't exist.md - i don't know whether this is intentional.

       [ERROR] file:///home/x/progs/lychee/fixtures/Doesn't%20exist.md |
       Wikilink file:///home/x/progs/lychee/fixtures/Doesn't%20exist.md not found at /home/x/progs/lychee/fixtures/home/x/progs/lychee/fixtures/Doesn't exist.md:
       WikiLink file:///home/x/progs/lychee/fixtures/Doesn't%20exist.md could not be found at /home/x/progs/lychee/fixtures/home/x/progs/lychee/fixtures/Doesn't exist.md
    
  • wikilinks always ignore fragments? i can't see anything in the obsidian help page which says they should be disregarded. the unit tests also seem to say that they should be resolved (unless "resolve" is meant as "ignore"). i note that if fragments were to be processed, the current markdown extractor would have to be changed. atm, it makes anchors using #kebab-case which is different to what obsidian uses in wikilinks.

  • wikilinks, if enabled, are tried on all file:// links, including absolute links. for instance, a link like [a](file:///tmp/Usage.md) could succeed when /tmp/Usage.md doesn't exist and a Usage.md exists inside the base folder. maybe it should be limited to relative links which only have filenames.

  • the wikilink feature does its own directory walk. this is different from other directory walks in lychee and won't respect options like gitignore or hidden files. actively ignoring symlinks is also weird.

  • to specify the indexing folder, i think --root-dir would've made more sense, or it could even be based off the inputs provided through command line. but it does work with --base-url so it's nbd.

Aside from the first point, I think these points are kinda hard to fix or don't necessarily need fixing. Just things to think about.

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.

5 participants