github-url-detection icon indicating copy to clipboard operation
github-url-detection copied to clipboard

Add `isRenderedTextFile` and `hasRenderedText` detection functions

Open Copilot opened this issue 1 month ago • 0 comments

Adds detection for pages displaying rendered markup content (markdown, textile, rdoc, org, creole, mediawiki, wiki, rst, asciidoc, pod) as specified in GitHub's markup gem.

Changes

  • isRenderedTextFile(url): Detects single file pages with rendered text extensions

    • Matches against: .md, .markdown, .mdown, .mkdn, .textile, .rdoc, .org, .creole, .mediawiki, .wiki, .rst, .asciidoc, .adoc, .asc, .pod
    • Case-insensitive extension matching
  • hasRenderedText(url): Composite detection for pages with rendered text

    • Returns true for repository root (README display) or rendered text files
    • Intentionally excludes SVG and other rendered content

Usage

import { isRenderedTextFile, hasRenderedText } from 'github-url-detection';

// Detect rendered text file
isRenderedTextFile(new URL('https://github.com/user/repo/blob/main/README.md')) // true
isRenderedTextFile(new URL('https://github.com/user/repo/blob/main/file.svg')) // false

// Detect any page with rendered text
hasRenderedText(new URL('https://github.com/user/repo')) // true (repo root)
hasRenderedText(new URL('https://github.com/user/repo/blob/main/docs.rst')) // true
Original prompt

This section details on the original issue you should resolve

<issue_title>hasRenderedText (markdown etc)</issue_title> <issue_description>```js export const isRenderedTextFile = isSingleFile && endsWith(md) export const hasRenderedText = isRepoRoot || isRenderedTextFile || etc


These shouldn't include SVG and other rendered content

Partially implemented in https://github.com/refined-github/refined-github/pull/4151/files#diff-a1b04b00ad1bdc63f8898dfbf43b2faf61ae3be4f50182d5a144d3e7f0dc7c29R14</issue_description>

<agent_instructions>The test is effectively /\.(textile|rdoc|org|creole|(media)?wiki|rst|a(scii)?doc|asc|pod)$/.test(location.pathname) but include markdown extensions.

origin: https://github.com/github/markup/blob/2b0e7f216904253092c90754cd95aac6d499583d/README.md</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

  • Fixes refined-github/github-url-detection#148

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Jan 14 '26 08:01 Copilot