antfu / vite-plugin-md

Markdown with Vue for Vite
MIT License
606 stars 89 forks source link

Cannot use <script lang= "ts" setup> in markdown #91

Closed ProsperBao closed 2 years ago

ProsperBao commented 2 years ago

I noticed a file script-hoisting.test.ts in the test case. I try to use the same syntax in example, but I failed. I tried a lot of ways. It seems that this part is all broken.

↓↓↓↓↓↓↓↓↓↓↓You can see examples here↓↓↓↓↓↓↓↓↓↓↓ demo ↑↑↑↑↑↑↑↑↑↑↑You can see examples here↑↑↑↑↑↑↑↑↑↑↑

image

image

image

yankeeinlondon commented 2 years ago

@FuBaooo I am working a new PR and I have switched in your test file as the repo's primary test mechanism as it supports your view that this is not working as it should.

yankeeinlondon commented 2 years ago

note that you can get everything to work if you're secondary script blocks are just <script> blocks and not <script setup> blocks, right? This is the difference which you introduced in repeating the <script setup> block multiple times which I'm not sure would ever have worked. Does it say it should work in the docs?

ProsperBao commented 2 years ago

I haven't tried <script> yet, but I think <script setup> should work normally since it is in the test case. I tried to copy the usage method in the test example, but failed.I think since it is in the test case, it should work

note that you can get everything to work if you're secondary script blocks are just <script> blocks and not <script setup> blocks, right? This is the difference which you introduced in repeating the <script setup> block multiple times which I'm not sure would ever have worked. Does it say it should work in the docs?

yankeeinlondon commented 2 years ago

The test case I had before worked fine but your test case added multiple <script setup> blocks which did not work. I think in general it would be a better idea for people to add <script> blocks in their code simply because the cardinality of <script> is 1:M but that said I have updated the test to the more aggressive test you introduced and I have all tests passing there too now with a little refactoring. This code isn't released yet but will be soon.

yankeeinlondon commented 2 years ago

this is fixed in v0.16.0