Skip to content

🐛 Bug: Allowed DOM elements and attributes less permissive than npm #1093

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

I noted this on the Discord (https://discord.com/channels/1464542801676206113/1464926468751753269/1466189688338518016): all my repos have fancy centered text and floating images that aren't (yet?) supported.

https://www.npmjs.com/package/create-typescript-app https://npmx.dev/package/create-typescript-app
Screenshot of create-typescript-app on npmjs.com with a centered h1 and right-aligned floating logo image Screenshot of create-typescript-app on npmx.dev with plain-text h1 and left-aligned logo image

@danielroe sent a link to:

const ALLOWED_ATTR: Record<string, string[]> = {
a: ['href', 'title', 'target', 'rel'],
img: ['src', 'alt', 'title', 'width', 'height'],
source: ['src', 'srcset', 'type', 'media'],
th: ['colspan', 'rowspan', 'align'],
td: ['colspan', 'rowspan', 'align'],
h3: ['id', 'data-level'],
h4: ['id', 'data-level'],
h5: ['id', 'data-level'],
h6: ['id', 'data-level'],
blockquote: ['data-callout'],
details: ['open'],
code: ['class'],
pre: ['class', 'style'],
span: ['class', 'style'],
div: ['class', 'style', 'align'],
}

I'll send a PR in a moment, just filing this issue for easier tracking. 🙂 It's more work than I'd hoped!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions