Conversation
| <meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'nonce-${nonce}'; style-src ${webview.cspSource} 'unsafe-inline'; img-src https: data: ${webview.cspSource}; font-src data: ${webview.cspSource};"> | ||
| <meta http-equiv="Content-Security-Policy" content=" | ||
| default-src 'none'; | ||
| script-src 'nonce-${nonce}' 'unsafe-eval'; |
There was a problem hiding this comment.
have to add 'unsafe-eval' to Content-Security-Policy to be able to execute WASM in the client/Visual-Editor.
| const me = this | ||
| main().then(result => { me.m = result }) |
There was a problem hiding this comment.
Sorry for this code, it loads the parser wasm and then sets it as the m property on the PandocConverter class.
| const wasmProducedASTString = this.m?.parse_qmd(markdown); | ||
| const wasmProducedAST = JSON.parse(wasmProducedASTString) | ||
|
|
||
| console.log(JSON.stringify(ast)) | ||
| console.log(JSON.stringify(wasmProducedAST)) |
There was a problem hiding this comment.
This is in the heart of where the qmd source is parsed, right before being turned into the prosemirror document that is the Visual Editor.
I tested some simple documents and we are able to parse them and convert them to prosemirror without using pandoc!
We have to be quite careful though, there has been a ton of pre and post processing being done to the pandoc AST previously. It is unclear if those are all hacks to fix issues with how the source is parsed, or if some of them add genuine functionality to the parse that qmd-parser wouldn't be doing.
32ad60d to
a4cbe8d
Compare
|
Rebased on |
This is an experiment to see if we can use a WASM build of quarto-markdown to parse qmd source when loading the Visual Editor.
We were able to! There is still much more testing to be done once we have a more feature-complete quarto-markdown.
When reading the "Files changed" in this PR, please ignore the files in
[apps/vscode-editor/src/wasm-qmd-parser/](https://github.com/quarto-dev/quarto/pull/871/files#diff-9066ed64f17eccb6ac009ae7293d2468718eeb3624b2daddfdfdcd2b7a0585ea), they are all copy&pasted from the WASM build of quarto-markdown. They would be imported somehow in the future.