Skip to content

Add components for cves, gh issues, and python downloadss#26

Merged
JacobCoffee merged 1 commit intomainfrom
new-components
Mar 3, 2026
Merged

Add components for cves, gh issues, and python downloadss#26
JacobCoffee merged 1 commit intomainfrom
new-components

Conversation

@JacobCoffee
Copy link
Member

Adds 3 new components to go with our existing:

  • CVE
  • GitHub Issue (we already have GH profile, gh rpeo)
  • Python releases
image image

Copilot AI review requested due to automatic review settings March 3, 2026 18:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new reference badge types to the existing “python refs” system so additional common URLs render as styled inline badges across posts.

Changes:

  • Extend remark-python-refs URL classification to recognize GitHub issues/PRs, NVD CVE detail pages, and python.org release pages.
  • Add new Lucide-based SVG icons for the new badge types.
  • Add global CSS theme styles for the new badge classes (ref-gh-issue, ref-cve, ref-py-release).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/plugins/remark-python-refs.ts Adds URL matchers and new RefType variants for GitHub issue/PR, CVE, and Python release links.
src/components/references/_icons.ts Introduces issueIcon, shieldIcon, and downloadIcon for the new badge types.
src/assets/styles/global.css Adds light/dark styling rules for the new badge class names.
Comments suppressed due to low confidence (3)

src/plugins/remark-python-refs.ts:130

  • RefType/classify() add gh-issue/cve/py-release, but the repo still only has explicit reference components for Pep/Docs/PyPi/GhRepo/GhUser, and the Markdoc tag parser (MARKDOC_TAG / markdocTagToBadge) also only recognizes those tags. If the PR goal is to add 3 new components (per PR description), add the missing Astro components and extend the Markdoc tag matcher/switch to support them; otherwise update the PR description to reflect that this change is URL-auto-detection only.
type RefType = "pep" | "docs" | "pypi" | "gh-repo" | "gh-user" | "gh-issue" | "cve" | "py-release";

interface Match {
  type: RefType;
  icon: string;
  label: string; // author's original link text — preserved
  url: string;
}

function extractText(children: PhrasingContent[]): string {
  return children
    .map((c) => {
      if (c.type === "text") return c.value;
      if ("children" in c) return extractText(c.children as PhrasingContent[]);
      return "";
    })
    .join("");
}

/** Match by link text — catches "PEP 649", "PEP 649," etc. */
const PEP_TEXT = /^PEP\s+\d+$/i;

function classify(url: string, linkText?: string): Omit<Match, "label" | "url"> | null {
  let m: RegExpMatchArray | null;

  // URL-based PEP detection
  if ((m = url.match(PEP_OLD)) || (m = url.match(PEP_NEW))) {
    return { type: "pep", icon: pythonIcon };
  }

  // Text-based PEP detection — catches links like [PEP 799](https://docs.python.org/...)
  if (linkText && PEP_TEXT.test(linkText.trim())) {
    return { type: "pep", icon: pythonIcon };
  }

  // CPython docs — checked after PEP text so [PEP NNN](docs.python.org/...) stays a PEP badge
  if (DOCS.test(url)) {
    return { type: "docs", icon: docsIcon };
  }

  if ((m = url.match(PYPI))) {
    return { type: "pypi", icon: packageIcon };
  }

  if ((m = url.match(GH_ISSUE))) {
    return { type: "gh-issue", icon: issueIcon };
  }

  if ((m = url.match(CVE))) {
    return { type: "cve", icon: shieldIcon };
  }

  if ((m = url.match(PY_RELEASE))) {
    return { type: "py-release", icon: downloadIcon };
  }

src/plugins/remark-python-refs.ts:38

  • The CVE URL matcher is more permissive than the documented format (CVE-YYYY-NNNNN): CVE-[\d-]+ will match invalid IDs like CVE-1-2 or CVE-2024-. Tighten this regex to the expected CVE structure (e.g., a 4-digit year and a numeric sequence of at least 4 digits) so non-CVE/partial strings don't get classified as CVE badges.
const GH_ISSUE = /^https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/(issues|pull)\/(\d+)\/?/i;
const CVE = /^https?:\/\/nvd\.nist\.gov\/vuln\/detail\/(CVE-[\d-]+)\/?/i;
const PY_RELEASE = /^https?:\/\/(?:www\.)?python\.org\/downloads\/release\/(python-[\w.]+)\/?/i;

src/assets/styles/global.css:1446

  • The comment block introducing the “Python community reference badges” section still lists only PEP/PyPI/GitHub repo/user badges, but this PR adds CSS for ref-gh-issue, ref-cve, and ref-py-release. Update the comment so it accurately reflects the supported badge types.
/* ── GitHub issue/PR — Green ────────────────────────── */

.prose .ref-gh-issue {
  color: #1a6d2e;
  background-color: rgba(34, 140, 60, 0.08);
  border-color: rgba(34, 140, 60, 0.2);
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JacobCoffee JacobCoffee merged commit 37778f1 into main Mar 3, 2026
7 checks passed
@JacobCoffee JacobCoffee deleted the new-components branch March 3, 2026 18:40
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.

2 participants