question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use custom (preprocessed) syntax in mdsvex files

See original GitHub issue

I tried to use SCSS in my layout svelte file and it gave me the error:

(node:14140) UnhandledPromiseRejectionWarning: ParseError: Colon is expected
    at error$1 (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\svelte\compiler.js:15595:20)
    at Parser$1.error (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\svelte\compiler.js:15671:10)
    at Object.read_style [as read] (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\svelte\compiler.js:11997:21)
    at tag (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\svelte\compiler.js:14737:34)
    at new Parser$1 (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\svelte\compiler.js:15630:22)
    at Object.parse$3 [as parse] (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\svelte\compiler.js:15761:21)
    at process_layouts (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\mdsvex\dist\main.cjs.js:25708:26)
    at Object.mdsvex (D:\Mudit and Harshit\Projects\svelte-materialify\site\node_modules\mdsvex\dist\main.cjs.js:25799:12)
    at Object.<anonymous> (D:\Mudit and Harshit\Projects\svelte-materialify\site\rollup.config.js:32:10)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)

But when I removed the lang attribute from my style tag and used CSS instead of SCSS, it showed no errors and worked fine.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

10reactions
michaeloliverxcommented, Jun 17, 2021

I hit an error while trying to use typescript in my layout files like this:

<script lang="ts">
  export let title: string;
</script>

<div class="mt-8 mx-auto prose">
  <h1>{title}</h1>
  <slot />
</div>

7reactions
jfcieslakcommented, Jan 9, 2022

A rather simple workaround to this that seems to do the job well, is to wrap your actual Layout in another “plain” svelte component, that only passes down frontmatter props. Apprently whatever is imported into layout file is still correctly preprocessed. E.g.:

<!-- WrappedLayout.svelte -->
<script lang="ts">
	import Layout from './Layout.svelte'
	export let someProp = ''
</script>

<Layout {someProp}>
	<slot />
</Layout>

The above will work just fine even if Layout.svelte is written in typescript or needs other preprocessors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mdsvex docs!
The preprocessor function accepts an object of options, that allow you to customise your experience. The options are global to all parsed files....
Read more >
svelte-exmarkdown - npm
You cannot use custom syntax(e.g. KaTeX). MDsveX is another good package. However, it is a preprocessor. Not suitable for dynamic rendering.
Read more >
svelte-exmarkdown - NPM Package Overview - Socket.dev
You cannot use custom syntax(e.g. KaTeX). MDsveX is another good package. However, it is a preprocessor. Not suitable for dynamic rendering.
Read more >
MDsveX - Adding Interactivity with Svelte Components in ...
This preprocessor allows you to use Svelte components in your markdown, ... be saved in a .svx file to be recognized as a...
Read more >
Recently Active 'remarkjs' Questions - Stack Overflow
I'm in svelte with the mdsvex package so I can easily use remark or rehype plugins. Say, next to my markdown file I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found