Skip to content

Odd, unexcludable behavior with ISO Dates #26

@RobTS

Description

@RobTS

Initial checklist

Affected package

remark-directive@4.0.0

Steps to reproduce

Sample code that produces weird output that tends to break on pages:

import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkDirective from 'remark-directive';
import remarkDirectiveRehype from 'remark-directive-rehype';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import rehypeComponents from 'rehype-components';

async function main() {
  const file = await unified()
    .use(remarkParse)
    .use(remarkDirective)
    .use(remarkDirectiveRehype)
    .use(remarkRehype)
    .use(rehypeComponents, {
      components: {},
    })
    .use(rehypeStringify)
    .process('2026-01-29T07:13:47.942Z');

  console.log(String(file));
}

main();

Actual behavior

The resulting output equates to <p>2026-01-29T07:13<47></47>.942Z</p>, as remarkDirective interprets the seconds as a directive, then remarkDirectiveRehype turns it into its own, non-existant <47> Tag. This breaks in React environments.

I can't seem to be able to limit directive interpretations to a whitelist, either, to leave ISO Dates untouched.

Expected behavior

ISO Dates should either be ignored by the parser, or there should be a way to limit directive interpretations to a whitelist (e.g. ['youtube', 'xyz'].

Runtime

node@24.11.1

Package manager

yarn@4.2.1

Operating system

macOS Tahoe 26.2

Build and bundle tools

Next.js, other (please specify in steps to reproduce)

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions