Skip to content

Fix broken .md links in generated OpenBolt docs#144

Closed
miharp wants to merge 1 commit into
OpenVoxProject:masterfrom
miharp:fix/openbolt-md-links
Closed

Fix broken .md links in generated OpenBolt docs#144
miharp wants to merge 1 commit into
OpenVoxProject:masterfrom
miharp:fix/openbolt-md-links

Conversation

@miharp
Copy link
Copy Markdown
Contributor

@miharp miharp commented May 2, 2026

Summary

  • Adds a rewrite_md_links step to the OpenBolt doc copy pipeline that converts relative .md cross-reference links to .html so they resolve correctly once Jekyll has processed the collection
  • Handles both markdown-style links [text](file.md) and raw HTML <a href="file.md"> attributes
  • Absolute http/https URLs are left untouched
  • Anchors (#section) are preserved

Why not jekyll-relative-links?

jekyll-relative-links was 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 each gsub block. Calling .sub() resets Regexp.last_match, so reading group 2 (the anchor) after it would silently return nil and drop #section from rewritten links.

Test plan

  • bundle exec rubocop lib/puppet_references/openbolt/docs.rb — no offenses
  • bundle exec rake references:openbolt INSTALLPATH=docs && bundle exec jekyll build — clean build
  • No href="*.md" links remain in _site/openbolt/latest/index.html
  • Anchored links (e.g. file.md#section) rewrite to file.html#section
  • Absolute URLs unchanged

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>
@miharp miharp marked this pull request as ready for review May 2, 2026 13:55
@miharp miharp requested a review from a team as a code owner May 2, 2026 13:55
@miharp miharp marked this pull request as draft May 2, 2026 14:01
@miharp
Copy link
Copy Markdown
Contributor Author

miharp commented May 2, 2026

Closing — parent PR #143 is being reverted. Will reopen once the missing generated reference pages are handled.

@miharp miharp closed this May 2, 2026
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>
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.

1 participant