Shiki Syntax Highlight
Answered
BakaPresident posted this in #help-forum
Hi there, any idea how i can differentiate between code tags and code blocks.
Single backticks and triple backticks.
I want to have customized code components upon codeblocks but i want codetags to stay the same
Single backticks and triple backticks.
I want to have customized code components upon codeblocks but i want codetags to stay the same
Answered by B33fb0n3
yea, when you have your if statement then just ask:
if(myString === "``\`") // remove the '\'
// is codeblock
else
// is inline code15 Replies
@BakaPresident Hi there, any idea how i can differentiate between code tags and code blocks.
Single backticks and triple backticks.
I want to have customized code components upon codeblocks but i want codetags to stay the same
yea, when you have your if statement then just ask:
if(myString === "``\`") // remove the '\'
// is codeblock
else
// is inline codeAnswer
ohh okayy
thanks
happy to help
@B33fb0n3 happy to help
Can i also check if i do
and
Why does my code still have the
<Markdown components={{
code(props) {
const { children, className, node, ...rest } = props
const match = /language-(\w+)/.exec(className || '')
return match ? (
<SyntaxHighlighter
language={match[1]}
style={docco}
children={String(children)}
/>
) : (
<code {...rest} className='border-2 rounded-md p-1'>
{children}
</code>
)
}
}}>
{message.content}
</Markdown>and
typography: {
DEFAULT: {
css: {
pre: false,
code: false
}
}
}Why does my code still have the
beforewhich caused something like
I think it's just a blog handlingn type of thing though
If u look at hello it doesn't have the backtickks for some reason
@BakaPresident Can i also check if i do
ts
<Markdown components={{
code(props) {
const { children, className, node, ...rest } = props
const match = /language-(\w+)/.exec(className || '')
return match ? (
<SyntaxHighlighter
language={match[1]}
style={docco}
children={String(children)}
/>
) : (
<code {...rest} className='border-2 rounded-md p-1'>
{children}
</code>
)
}
}}>
{message.content}
</Markdown>
and
typography: {
DEFAULT: {
css: {
pre: false,
code: false
}
}
}
Why does my code still have the `before`
if you want a whole markdown system you normally don't work with the stuff I mentioned. Instead you should use a markdown library. If you want the markdown exactly the same like discord, I suggest you
discord-markdown. You can see an example on how to use it here: https://github.com/rafaelalmeidatk/nextjs-forum/blob/main/apps/web/utils/discord-markdown.ts#L105@B33fb0n3 if you want a whole markdown system you normally don't work with the stuff I mentioned. Instead you should use a markdown library. If you want the markdown exactly the same like discord, I suggest you discord-markdown. You can see an example on how to use it here: https://github.com/rafaelalmeidatk/nextjs-forum/blob/main/apps/web/utils/discord-markdown.ts#L105
Ohh okay i thought react markdown could render everything correct
@BakaPresident Ohh okay i thought react markdown could render everything correct
yea it can. But "correct" is quite a big word. It could mean something to you and mean something different to me
@B33fb0n3 yea it can. But *"correct"* is quite a big word. It could mean something to you and mean something different to me
righttt for me i just wanted it to look right and all the bolded things / list and everything looks good to me
I'll just stick with this first and if i wanna edit later then i edit
doing this for a school work