-
Notifications
You must be signed in to change notification settings - Fork 13
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
Integration with VS Code using a VS Code extension #37
Comments
There's an issue open with the VS code python extension to allow sending code to the interactive window from a markdown file if it's within code cells. All you would have to do then would be to set it reading codebraid cells as python cells. microsoft/vscode-python#13568 |
I've thought about an extension in the past, but haven't tried anything. I agree that an alternative way to run codebraid would be nice...unfortunately, my time is very limited and I don't have much experience with programming JavaScript/TypeScript and graphical user interfaces. Depending on what features you want, it seems like a Markdown extension with Pandoc support would be a good starting point. The last time I looked, I didn't find anything, but I just looked again, and how there's https://github.com/kzvi/vsc-pandoc-markdown-preview. I installed it and made a few changes to diff ./preview_panel.js ./codebraid_preview_panel.js
20a21
> this.katexPath = katexPath;
22a24
> this.cssPath = cssPath;
68,69c70,71
< pandocOptions.push(`--katex=${this.katexUri}/`);
< pandocOptions.push(`--css=${this.cssUri}`);
---
> //pandocOptions.push(`--katex ${this.katexUri}/`);
> pandocOptions.push(`--css ${this.cssPath}`);
71,72c73,74
< pandocOptions.push('--metadata=header-includes:{{pmp-base-tag}}');
< this.subprocess = child_process_1.exec(`pandoc ${pandocOptions.join(' ')}`, execOptions, (err, stdout, stderr) => {
---
> pandocOptions.push('--metadata header-includes:{{pmp-base-tag}}');
> this.subprocess = child_process_1.exec(`codebraid pandoc -f markdown -t html ${pandocOptions.join(' ')}`, execOption s, (err, stdout, stderr) => { This requires the dev version of This extension doesn't have scroll sync. However, I've already designed and partially implemented a way to get codebraid working with SyncTeX (jump back and forth between Markdown and LaTeX PDF output). So if I knew what data was needed to get scroll sync working with HTML, I expect this could be solved. |
Any updates? It appears that there is still not an extension available on VS Code's market space for Codebraid. |
@matrix-ranger For the moment, I still don't have any better suggestions than taking an existing VS Code extension like https://github.com/kzvi/vsc-pandoc-markdown-preview and customizing the subprocess command to use codebraid instead of pandoc. I'm currently working on improving error handling to simplify debugging. Once that is done, I will be implementing a mapping between Markdown input line numbers and LaTeX/HTML output line numbers/locations. This will make possible SyncTeX for LaTeX and scroll sync for HTML. Once that is done, I will see what I can do about a VS Code extension, if no one else has tried first. At least to start with, I'll be trying to create a Markdown preview pane that uses codebraid to generate the HTML and has scroll sync. This appears to be relatively straightforward by combining a VS Code webview with sync triggered by My impression from browsing through the VS Code issues is that there is a lot of work being done to extend VS Code's current interface for working with Python Jupyter notebooks to support a wider range of notebooks/markdown+code tools. If something like that becomes possible for a format like MyST Markdown or R Markdown, then it should be possible to extend the same approach for Codebraid. |
Thanks for the reply. Indeed a Markdown preview pane that uses Codebraid to generate the HTML sounds like the best solution here. Up to now, I can't find an extension that can preview R/MyST Markdown well though I am using Markdown Preview Enhanced as a temporary workaround. MPE has the option of extending Markdown parser by user-defined JS scripts and customizing CSS, and I use this to help it recognize the code blocks and containers in R/Codebraid Markdown. |
I'm now working on an extension for VS Code. This will provide a preview window with scroll sync. At least at first, the preview may not update until all code has executed, However, I'm trying to finish a redesign of the Codebraid internals that should allow the preview to update nearly instantly during code execution with the latest output. I'm currently in the process of finishing scroll sync and am just about to start on integrating Codebraid. I'm hoping to release an initial version of the extension and ideally a new version of Codebraid as well within 2-4 weeks. Question for those who are interested in a VS Code extension: What features do you consider most important or useful in an extension, besides preview with scroll sync and fast updates? I may not have time or interest to do much more than that, but I'm interested in getting ideas in case some design decisions now can provide more options (for me or others) in the future. |
I think just that feature would be great! Thank you for working on this! |
The VS Code extension is now available: https://marketplace.visualstudio.com/items?itemName=gpoore.codebraid-preview. This requires the absolute latest Pandoc and Codebraid versions for best results. This should be quite usable. There may be a few aspects of scroll sync that need to be polished in the future to provide a slightly smoother experience. Eventually there may also need to be some document templates to make the default exported documents a little less plain. Currently, the preview refreshes automatically when you are just using Pandoc, but it requires manual refresh for Codebraid. I've just finished completely reimplementing the internals as async to support better |
Wow, this looks amazing! Will have a play and come back with any issues but definitely clears the initial ask (and then some). |
Would it be possible to have a VS code extension that runs codebraid? I see there's a similar open issue with Spyder integration (#17). The main motivation would be to make it easier and more user-friendly to run codebraid (in my experience, not everyone is comfortable using the command line).
The text was updated successfully, but these errors were encountered: