Skip to content

Convert relative paths to absolute when checking links #37

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

Merged
merged 4 commits into from
Jun 12, 2020

Conversation

mattcopas
Copy link
Contributor

This solution takes a relative link to check (eg ../../test/a) and converts it to an absolute link (/docs/test/a).

This also adds a second attempt at finding headers for links - ie if finding headers for /a fails, then try again for /a/

Closes #28

@mattcopas mattcopas requested a review from stuarthendren June 12, 2020 15:36
Copy link
Contributor

@stuarthendren stuarthendren left a comment

Choose a reason for hiding this comment

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

Also update the version (in all 3 package.json)

To link relatively to the folder `b` you should use, [b/](b/) or [b/index](b/index) the last has the advantage that is also works in the raw markdown. A full link is also valid [/tests/a/b/](/tests/a/b/) or [/tests/a/b/index](/tests/a/b/index) linking to headings is also supported [b/#link-test](b/#link-test) and [b/index#link-test](b/index#link-test).
To link relatively to the folder `b` you should use, [b/](b/) or [b/index](b/index) the last has the advantage that is also works in the raw markdown. A full link is also valid [/tests/a/b/](/tests/a/b/) or [/tests/a/b/index](/tests/a/b/index) linking to headings is also supported [b/#link-test](b/#link-test) and [b/index#link-test](b/index#link-test).

You can also link 'up' directories, for example: [../a](../a), [../a/mdTest](../../tests/mdTest), [../../tests/a/b#link-test](../../tests/a/b#link-test)
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT I don't like these examples as they come back in to a or it's children they are not links you would actually write.

Also the second one is different in the display and the actual link.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated link text

Not intending to change the links themselves. Agree they are contrived but they're there to demonstrate the concepts of "upward relative" linking and they do that adequately IMO.

@mattcopas mattcopas requested a review from stuarthendren June 12, 2020 16:57
@stuarthendren stuarthendren merged commit 262051a into master Jun 12, 2020
@stuarthendren stuarthendren deleted the mc-fix-upward-relative-links branch June 12, 2020 17:17
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.

Can type incorrect path and still work but breaks links
2 participants