Closed SeungyeopShin closed 10 months ago
Expressions in jsxslack
template literal tag are always escaped, and cannot mix non jsx-slack components. markdown-to-jsx
is designed for React, not jsx-slack.
To convert the string representation of HTML into Slack Mrkdwn, you can use jsxslack
as a function just like this:
import { jsxslack } from 'jsx-slack';
// HTML should be jsx-slack compatible
const html = '<p><b>Our Project</b></p><p>Hello, <b>Markdown</b>!</p>';
const result = jsxslack([`<Mrkdwn>${html}</Mrkdwn>`]);
console.log(result.text); // *Our Project*\n\nHello, *Markdown*!
You can pass the string representation of HTML that is converted from Markdown.
See also:
This is exactly how our REPL demo converts the string to actual JSX.
Note that the string is wrapped in an array. Once you understand how the template literal tag works, you may understand why this works like magic :)
— https://github.com/yhatt/jsx-slack/issues/307#issuecomment-1842183952
Thanks for you reply. I successed with marked.
Hello, I tested jsx-slack to convert standard markdown to slack markdown. But I can't get the result I want.
How could I get correct json object with slack markdown.