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

Example doesn't work #84

Open
legodude17 opened this issue Oct 12, 2022 · 3 comments
Open

Example doesn't work #84

legodude17 opened this issue Oct 12, 2022 · 3 comments

Comments

@legodude17
Copy link

  • remark-embedder-core version: 3.0.1
  • node version: 18.4.0
  • npm version: 8.13.0

Relevant code or config

Example in the README.

What you did:
Ran the code.

What happened:

Got an error:

import remark from 'remark'
       ^^^^^^
SyntaxError: The requested module 'remark' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
    at async loadESM (node:internal/process/esm_loader:85:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Node.js v18.4.0

After fixing this, it runs but does not embed properly.

After fixing that, the URL is completely removed.

Suggested solution:

For the first issue, you must wrap remark in brackets.

For the second, you need to add a .default when using remarkEmbedder.

For the third, you need to add { sanitize: false } when using the remark-html plugin, since otherwise it's sanitization will remove the iframe.

@gabriel-rh
Copy link

Thanks @legodude17 ! This was so frustrating

@rafter-GMSVK
Copy link

Hey @legodude17 can you please tell where should I make step 2 and 3 changes. I would really appreciate if you can give me an example.

Thank you so much.

@legodude17
Copy link
Author

For step 2, it is whenever you use remarkEmbedder you must instead write remarkEmbedder.default. For step 3, when you use html, you can pass it options as the second argument of .use, where you have to say { sanitize: false}. Starting with the go function from the example, the result (that should actually work), should look like this:

async function go() {
  const result = await remark()
    .use(remarkEmbedder.default, {
      transformers: [CodeSandboxTransformer],
    })
    .use(html, { sanitize: false })
    .process(exampleMarkdown)

  console.log(result.toString())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants