ssssota / svelte-exmarkdown

Svelte component to render markdown.
https://ssssota.github.io/svelte-exmarkdown
MIT License
189 stars 6 forks source link

How we can render html tags and custom tags #28

Closed projectashik closed 1 year ago

projectashik commented 1 year ago

I am trying to add support of html tags inside markdown but haven't found any working solution yet. And I also want to render the custom tags.

ssssota commented 1 year ago

I am trying to add support of html tags inside markdown but haven't found any working solution yet.

Oh, yes. It certainly doesn't seem to be supported yet. I'll try to support it!

And I also want to render the custom tags.

You want to support custom tags in Markdown? More specific examples would be helpful!

ssssota commented 1 year ago

I have released new version v2.0.0! This version includes html support. If you render HTML, you should use with rehype-raw as rehypePlugin.

AgarwalPragy commented 1 year ago

Can you help me understand what I'm doing wrong?

updated to 2.0.0, added rehype-raw and ran pnpm install.

    "rehype-raw": "^6.1.1",
    "svelte-exmarkdown": "^2.0.0",

Added a plugin

import type { Plugin } from 'svelte-exmarkdown'
import rehypeRaw from 'rehype-raw'

export const MARKDOWN_PLUGINS: Plugin[] = [
  { rehypePlugin: rehypeRaw },
  ...
]
<Markdown {md} plugins={MARKDOWN_PLUGINS} />

It still strips off all the HTML tags from the following content

<b>Hello</b>, <span class="text-secondary-500">world</span>!
ssssota commented 1 year ago

@AgarwalPragy Thank you for using it so quickly! Hmm. I don't see why it wouldn't work. Maybe there is a problem with the order of the plugins.

Please check this demo: https://stackblitz.com/edit/svelte-exmarkdown-28-demo?file=src/App.svelte

AgarwalPragy commented 1 year ago

My bad. Seems like it was an issue on my side.

I had to run the following to get it to work.

rm -rf node_modules
rm pnpm-lock.yaml
pnpm store prune
pnpm install

Weird that I had to bust the pnpm cache. 🤷

AgarwalPragy commented 1 year ago

Thanks a ton for the quick reply!

Also, do you know why the official Svelte REPL is unable to handle svelte-exmarkdown?

https://svelte.dev/repl/86df1b2602ec4606990d3ffe4fad2ca5?version=3.55.1

It throws a Unexpected token (Note that you need plugins to import files that are not JavaScript) the moment you try to import the package

ssssota commented 1 year ago

Also, do you know why the official Svelte REPL is unable to handle svelte-exmarkdown?

Sorry, I don't know. 🤔