Keep renderer-owned fences out of artifact promotion

Artifact detection runs before the rich-fence registry, so a fence long
enough to look like a code document was promoted to a code card and never
reached its own renderer. A multi-listing set crosses that threshold
easily, which made the same content render two different ways depending on
how many properties it held.

`listing` joins the languages that are never artifacts, next to `mermaid`
for the same reason.
This commit is contained in:
Brooklyn Nicholson
2026-09-04 14:18:39 -05:00
committed by brooklyn!
parent 9b16719e17
commit cb6cb74696
2 changed files with 12 additions and 1 deletions
@@ -78,6 +78,13 @@ describe('detectArtifact', () => {
expect(detectArtifact('markdown', longCode(80))).toBeNull()
expect(detectArtifact('mermaid', longCode(80))).toBeNull()
})
it('leaves rich-renderer fences alone however long they get', () => {
// Detection runs before the rich-fence registry, so a long `listing` set
// (or any renderer-owned language) would otherwise be stolen by the code
// card and never render as its own component.
expect(detectArtifact('listing', longCode(200))).toBeNull()
})
})
describe('artifactSlug', () => {
+5 -1
View File
@@ -34,11 +34,15 @@ const CODE_MIN_CHARS = 3000
const HTML_LANGUAGES = new Set(['html', 'htm', 'xhtml'])
// Languages whose fences are never artifacts: prose-ish, terminal output, and
// the fences already owned by richer renderers (mermaid diagrams, small svg).
// the fences already owned by richer renderers (mermaid diagrams, small svg,
// listing cards). Artifact detection runs BEFORE the rich-fence registry, so a
// language that has its own renderer must opt out here or a long enough fence
// gets promoted to a code card and never reaches it.
const NON_ARTIFACT_LANGUAGES = new Set([
'',
'console',
'diff',
'listing',
'log',
'logs',
'markdown',