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

Fix local anchor link issue #21

Merged
merged 1 commit into from
Apr 17, 2021

Conversation

saswatamcode
Copy link
Collaborator

Currently, mdox throws an error for markdown anchor links which don't begin with # and contain a /, even though GitHub or frameworks like Hugo parse them correctly (same file or different one) such as this or this. The below errors are thrown even when file and anchor id exist,

mdox fmt -l storage.md
(6 occurrences): link design.md/#chunk, normalized to: failed to stat /Users/saswatamukherjee/web/thanos/docs/design.md/: stat /Users/saswatamukherjee/web/thanos/docs/design.md/: not a directory

mdox fmt -l design.md
(2 occurrences): link design.md/#chunk-file, normalized to: failed to stat /Users/saswatamukherjee/web/thanos/docs/design.md/: stat /Users/saswatamukherjee/web/thanos/docs/design.md/: not a directory

With this fix, the links are validated correctly and, when given options, are transformed from design.md/#chunk to design.md#chunk(if anchor is in diff file) or simply #chunk(if in same file). Test case has been added to check the same.

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
@bwplotka bwplotka self-requested a review April 17, 2021 18:04
Copy link
Owner

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

💪🏽 Thanks, makes sense!

@bwplotka bwplotka merged commit 50f4844 into bwplotka:master Apr 17, 2021
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.

None yet

2 participants