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

Can't render string Markdown with compile() #697

Open
AnzeKop opened this issue Feb 26, 2025 · 0 comments
Open

Can't render string Markdown with compile() #697

AnzeKop opened this issue Feb 26, 2025 · 0 comments

Comments

@AnzeKop
Copy link

AnzeKop commented Feb 26, 2025

We have a project where we store markdown data in the database and need to fetch this on the server to then render on the frontend.

Reading the docs the compile function looks to be the way to implement this but as this spits out svelte code wrapped in a string its not possible to render it using `{@render content()} and rendering using {@html content} gives wierd outcomes:

const questionData = {
	title: 'Sample Question',
	content: `## This is a sample question. 
	It is used to test the FAQ page when no question is found. 
	\`\`\`ts
	const sample = 'sample';
	\`\`\`
	`,
	slug: 'sample-question'
};

const compiledContent = await compile(questionData.content);
Image
<div class="container">
	<div class="prose">
		{@html questionData.content.code}
	</div>
</div>
@github-project-automation github-project-automation bot moved this to Triage + Refine in mdsvex Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage + Refine
Development

No branches or pull requests

1 participant