Skip to content

okf: fix visualize edges for absolute and titled cross-links#184

Open
manumishra12 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
manumishra12:fix/viz-edges-absolute-and-titled-links
Open

okf: fix visualize edges for absolute and titled cross-links#184
manumishra12 wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
manumishra12:fix/viz-edges-absolute-and-titled-links

Conversation

@manumishra12

Copy link
Copy Markdown

What

The reference visualize tool extracts 0 edges from bundles whose cross-links use either form that okf/SPEC.md treats as valid:

  • Absolute bundle-relative links (e.g. /tables/users.md), which the SPEC's cross-linking guidance recommends, and
  • CommonMark link titles (e.g. [Users](users.md "the users table")).

Only relative, untitled links produced edges, so otherwise spec-conformant bundles rendered as disconnected node clouds.

Why

In okf/src/reference_agent/viewer/generator.py:

  • _extract_links skipped every /-prefixed target (if "://" in target or target.startswith("/")), dropping the recommended absolute form.
  • _LINK_RE left no room for a link title, so ](path.md "title") — valid CommonMark — did not match at all.

Fix

  • Resolve /-prefixed targets against the bundle root instead of skipping them.
  • Allow an optional CommonMark title ("..." or '...') in the link-extraction regex.

Both changes are confined to link extraction; node and edge building are unchanged. External (://) links are still ignored, and dangling links still produce no edge.

Tests

Adds two regression tests to okf/tests/test_viewer.py:

  • test_titled_links_become_edges
  • test_absolute_bundle_relative_links_become_edges

Each fails on the current code (0 edges) and passes with this change. Full viewer suite: 8 passed.

Notes

Addresses #48. This is a deliberately small, test-covered change scoped only to the visualizer's edge extraction, offered as a focused alternative to the broader #66 (which also reworks SPEC text across the codebase). Happy to adjust scope if maintainers prefer.

The reference visualize tool extracted zero edges from spec-conformant
bundles that use either absolute bundle-relative links (recommended by
SPEC.md) or standard CommonMark link titles, so such bundles rendered as
disconnected node clouds.

- Resolve /-prefixed link targets against the bundle root instead of
  skipping them.
- Allow an optional CommonMark link title in the link-extraction regex.

Adds regression tests for both link forms.
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