Add components for cves, gh issues, and python downloadss#26
Merged
JacobCoffee merged 1 commit intomainfrom Mar 3, 2026
Merged
Add components for cves, gh issues, and python downloadss#26JacobCoffee merged 1 commit intomainfrom
JacobCoffee merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
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-refsURL 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()addgh-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 likeCVE-1-2orCVE-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, andref-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.
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.
Adds 3 new components to go with our existing: