Leading whitespace in code blocks breaks all subsequent highlighted codeblocks
Describe the bug
If you have a leading white space in a codeblock, it will break the parser such that having subsequent highlighted codeblocks will crash the current slide.
This is an issue for assembly which often has leading whitespace. This is also where I encountered this problem.
Minimal reproduction
https://stackblitz.com/edit/github-sspw9v?file=slides.md=
block 1
```
test
```
block 2
```js
const val = 42
```
Environment
- Slidev version: 0.49.29
- Browser: Chrome
- OS: MacOS
Thanks for the report! I also encountered same exception this afternoon, but slightly different cause.
```python {all}{lines: true}
print(test)
```
It won't occur if there's no {lines: true}
the leading blank line will cause same issue. Thanks to the report, provide me a clue.
I am sorry for the late reply.
@EmNudge I've opened https://github.com/slidevjs/slidev/pull/1909 to allow leading whitespace in code blocks.
@zillionare In my opinion the leading empty lines are invalid. Because Slidev wraps code blocks before passing the code to the Markdown parser, we may not be able to handle them correctly.
@KermanX
Thank you for the answering my question.
Although my example may not be syntactically correct, I believe many others might also be confused about the formatting requirements here. So, it would be helpful to keep this as a record.
It would be even better if there could be a section in the documentation or discussions dedicated to recording these invalid cases that people often make mistakes with.