-
Notifications
You must be signed in to change notification settings - Fork 46
Experimental: wasm qmd parser for VE loading #871
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
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.