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

Add support to a checker for markdown links #167

Open
jenkin opened this issue Jun 13, 2023 · 6 comments
Open

Add support to a checker for markdown links #167

jenkin opened this issue Jun 13, 2023 · 6 comments
Assignees

Comments

@jenkin
Copy link
Contributor

jenkin commented Jun 13, 2023

Problem

Links in markdown (ie. [anchor](absolute url or relative local path)) can be broken. Raneto doesn't have a built-in link checker or doesn't support custom plugins.

Requirements

A link checker validating both external links (ie. https://...) and relative local path (ie. ../dir/page.md) with anchors (ie. ../dir/page.md#chapter-1).

Proposed solution

There are many tools available to validate links in html or markdown files, ie. markdown-link-validator. We can integrate it in Makefile.

check:
    npx --yes markdown-link-validator ./content

So we can check all links running make check.

Output.

/home/jenkin/Progetti/sparkfabrik/company-playbook/content/tools-and-policies/access-to-the-office-during-covid19-pandemic.md
✔ https://calendar.google.com/calendar/u/1/embed?src=agavee.com_1eaeflfo4q9siffm4bj6umkpuk@group.calendar.google.com&ctz=Europe/Rome
✖ https://calendar.google.com/calendar/ical/agavee.com_1eaeflfo4q9siffm4bj6umkpuk%40group.calendar.google.com/private-999297412c557aade34f6654b5e2b923/basic.ics:17:232
✔ https://www.gazzettaufficiale.it/atto/serie_generale/caricaDettaglioAtto/originario?atto.dataPubblicazioneGazzetta=2020-10-07&atto.codiceRedazionale=20G00144&elenco30giorni=false
✔ #responsible-for-security

Found 4 links:
    3 valid
    1 invalid

Drawbacks

For markdown-link-validator a valid internal link should have a relative path (no leading /) and a .md extension (see https://github.com/webhintio/markdown-link-validator/blob/main/src/lib/mdfile.ts#L178).

Alternatives

@jenkin jenkin self-assigned this Jun 13, 2023
@stickgrinder
Copy link
Member

This is a great idea. One thing that we may want to do is providing a git-hook which runs the check before commit or push events, because being Raneto a running service, you make it once and it reflects the markdown files on the fly. This would rule out the check after the first make issuing.

@jenkin
Copy link
Contributor Author

jenkin commented Jun 13, 2023

@stickgrinder I added a drawbacks section and published a working experiment in 167-exp-link-checker branch.

@stickgrinder
Copy link
Member

can you please open a draft PR with your work so I can review it with ease?

@jenkin
Copy link
Contributor Author

jenkin commented Jun 21, 2023

Here is my enhanced fork of markdown-link-validator: https://github.com/jenkin/markdown-link-validator/tree/feature/sparkfabrik-enhancements. All fixes merged in #170 come from that enhanced version.

jenkin added a commit that referenced this issue Jun 22, 2023
jenkin added a commit that referenced this issue Jun 22, 2023
Using [markdown-link-validator](https://github.com/jenkin/markdown-link-validator/tree/feature/sparkfabrik-enhancements) from github repo.

Build the docker image and run validation with `make check`.
@jenkin
Copy link
Contributor Author

jenkin commented Jun 22, 2023

All fixes proposed in #172 come from enhanced version of markdown-link-validator.

In #173 it is integrated in playbook Makefile.

jenkin added a commit that referenced this issue Jun 26, 2023
Using [markdown-link-validator](https://github.com/jenkin/markdown-link-validator/tree/feature/sparkfabrik-enhancements) from github repo.

Build the docker image and run validation with `make check`.
jenkin added a commit that referenced this issue Jun 26, 2023
jenkin added a commit that referenced this issue Jun 26, 2023
See
[issues/167#issuecomment-1589456767](#167 (comment)).
stickgrinder pushed a commit that referenced this issue Jun 27, 2023
* refs #167: add support to link check

Using [markdown-link-validator](https://github.com/jenkin/markdown-link-validator/tree/feature/sparkfabrik-enhancements) from github repo.

Build the docker image and run validation with `make check`.

* refs #167: update link checker

* refs #167: add pre-commit hook

See
[issues/167#issuecomment-1589456767](#167 (comment)).
@stickgrinder
Copy link
Member

@jenkin I merged this, will try and do some testing adding stuff to the pages you created, before closing the card.

@stickgrinder stickgrinder self-assigned this Jun 27, 2023
stickgrinder pushed a commit that referenced this issue Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants