Fix broken .md links in generated OpenBolt docs#144
Closed
miharp wants to merge 1 commit into
Closed
Conversation
The upstream bolt docs use relative .md links for cross-references (both markdown-style [text](file.md) and raw HTML <a href="file.md">). Jekyll serves the collection as .html, so those links 404. Adds a rewrite_md_links step in the copy pipeline that converts relative .md links to .html while leaving absolute http/https URLs alone. Anchors (#section) are preserved by capturing Regexp.last_match groups before calling .sub() — that call resets the match state, which would otherwise silently drop the anchor. The jekyll-relative-links plugin was evaluated as an alternative but only processes markdown-style links converted through Kramdown; it does not touch raw HTML <a href="..."> attributes, which is the predominant link format in the bolt docs. The in-pipeline rewrite covers both cases. Signed-off-by: Michael Harp <mike@mikeharp.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Closing — parent PR #143 is being reverted. Will reopen once the missing generated reference pages are handled. |
tuxmea
pushed a commit
that referenced
this pull request
May 2, 2026
Reverts #143 while the following issues are resolved: 1. **Broken internal links (94):** The bolt documentation references several pages that are generated from ERB templates in `documentation/templates/` rather than existing as static markdown. These pages — including `plan_functions.md`, `bolt_types_reference.md`, `bolt_transports_reference.md`, `bolt_project_reference.md`, `bolt_defaults_reference.md`, `bolt_command_reference.md`, `bolt_cmdlet_reference.md`, and `packaged_modules.md` — are absent from the copy pipeline, leaving 94 internal links as 404s. 2. **Relative .md links:** The upstream docs use relative `.md` links for cross-references. Jekyll serves the collection as `.html`, so those links also 404 without a rewrite step in the pipeline (tracked in #144). A follow-up PR will address both issues before re-landing the OpenBolt docs. Signed-off-by: Michael Harp <mike@mikeharp.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rewrite_md_linksstep to the OpenBolt doc copy pipeline that converts relative.mdcross-reference links to.htmlso they resolve correctly once Jekyll has processed the collection[text](file.md)and raw HTML<a href="file.md">attributeshttp/httpsURLs are left untouched#section) are preservedWhy not
jekyll-relative-links?jekyll-relative-linkswas evaluated first. It only processes markdown-style links after Kramdown converts them — it does not touch raw HTML<a href="...">attributes that appear verbatim in the source. The bolt docs use raw HTML for most of their cross-references (e.g. the "Helpful Bolt docs links" table on the index page), so the plugin left the majority of broken links unresolved. The in-pipeline rewrite covers both formats in one pass.Implementation note
Capture groups are assigned to local variables before calling
.sub()inside eachgsubblock. Calling.sub()resetsRegexp.last_match, so reading group 2 (the anchor) after it would silently returnniland drop#sectionfrom rewritten links.Test plan
bundle exec rubocop lib/puppet_references/openbolt/docs.rb— no offensesbundle exec rake references:openbolt INSTALLPATH=docs && bundle exec jekyll build— clean buildhref="*.md"links remain in_site/openbolt/latest/index.htmlfile.md#section) rewrite tofile.html#section