Skip to content

Fix local anchor link issue - #21

Merged
bwplotka merged 1 commit into
bwplotka:masterfrom
saswatamcode:anchor-link-fix
Apr 17, 2021
Merged

bwplotka merged 1 commit into
bwplotka:masterfrom
saswatamcode:anchor-link-fix

Conversation

@saswatamcode

Copy link
Copy Markdown
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

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Owner

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.

2 participants

⌂ 换网址