Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate does not inject the react props into MarkDown links #2600

Closed
4 tasks done
ChezMose opened this issue Mar 21, 2025 · 2 comments
Closed
4 tasks done

Evaluate does not inject the react props into MarkDown links #2600

ChezMose opened this issue Mar 21, 2025 · 2 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@ChezMose
Copy link

ChezMose commented Mar 21, 2025

Initial checklist

Affected package

@mdx-js/[email protected]

Steps to reproduce

Context

A client-side React application

Repro

import React from 'react';
import * as runtime from 'react/jsx-runtime'
import { evaluate } from '@mdx-js/mdx';

/* ---------------------------------------
  Create a component with the given injectable expression
--------------------------------------- */
const useInjectable = (
  expression,
) => {
  const [component, setComponent] = React.useState(() => () => <div>--</div>);

  React.useEffect(() => {
    evaluate(expression, runtime)
      .then(({ default: evaluated }) => {
        setComponent(() => evaluated);
      });
  }, [])

  return component;
}

/* ---------------------------------------
  Test the hook
--------------------------------------- */
export const TestInjectable = () => {
  const Component = useInjectable('### Reach us by email: [{props.email}](mailto:{props.email})');

  return (
    <div className="whatever">
      <Component
        email="[email protected]"
      />
    </div>
  );
};

Actual behavior

The email prop is correctly injected into the text part of the link, but not into the href.

<h3>Reach us by email: <a href="mailto:%7Bprops.email%7D">[email protected]</a></h3>

My first guess what that Url encoding occurred before the injection, but I've had a similar behavior using an actual 'a' tag.
My second guess is that it's a security matter, but that's a real limitation in my case.

Expected behavior

I wonder if it's an issue or an intended behavior.
And I am interested if there is a way to force the injection.

Runtime

Any web browser

Package manager

[email protected]

Operating system

Windows 11

Build and bundle tools

webpack

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Mar 21, 2025
@remcohaszing
Copy link
Member

Duplicate of #2493

@remcohaszing remcohaszing marked this as a duplicate of #2493 Mar 21, 2025
@remcohaszing remcohaszing closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2025

This comment has been minimized.

@remcohaszing remcohaszing added 🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants