-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Standardizing notebook renderer api #123540
Comments
This looks sensible to me. @vijayupadya is the point of contact for aznb. For this we would switch to loading to loading renderers via ES6 Should we apply the this treatment to kernel preloads? This could make them slightly harder to author -- for example, I could no longer just take jquery.min.js and stick it in a preload -- but would standardize all renderer script loading and remove a lot of code from our webviewPreloads.ts. Wrt switchover: we can probably support both safely for a bit; if the Adding myself on here to help out 🙂 |
Would it be possible to provide some information that would help extension authors link a cell in a notebook to an output that's being rendererd? interface ICellCreateInfo {
cellUri: Uri
readonly kind: 'markup' | 'output';
Is it possible to have a dependency or preloads section. In Jupyter we'd like to load |
@connor4312 Yes we'd want to use dynamic imports instead. I have this implemented with the existing markup renderers Not sure about kernel preloads since I'm not as familiar with them. Is the concern that you'd no longer be able to pull in a jquery global to make it accessible in renderer scripts? Could preload assign to |
I remember TypeScript producing errors trying to import a file without exports, but it looks like in browsers I can do something like When do you plan to implement this? I would like to get #123601 done tomorrow (if uncontroversial) to unblock Don, but if you think this is ready to go then those IPC changes can be done afterwards. Looking forward to this refactor, it'll make lots of things nicer 👍 Let me know if there's any way I can assist or parts you would like me to implement. |
This implements the api described in #123540. Major points: - Instead of having the `markdown-it` renderer pull it its dependencies, instead the dependencies can call `getRenderer` to import the object returned by the `markdown-it` renderer - We try to detect if a renderer is using the old or new api. Old renderers are still run as globals while new ones are loaded with `import` - I have only hooked up the new API for markdown renderers so far
@connor4312 Here's a first cut at implementing the proposed API: #123738. I could use your help properly hooking up the output renderers and making sure this won't cause regressions for them Can you also please make sure the AZ notebooks team is aware of this work. I've added significant background in the original comment which should better explain the rational and benefits of this proposed change |
When rendering markdowns, we'll need to know the cell uri, so we can pull some metadata from the cell notebook. See here #123021 |
Should we consider to send the cell data (or the cell metadata) as part of the renderer request? This wouldn't be mutual exclusive to renderer IPC but certainly an easy solution for this |
Yes, that should be part of |
Tracks standardizing (and potentially unifying) the notebook markup and output renderer apis. These two should at least be similar shapes so that they are easier to work with
Split from #105933
Current state
We recently added extensible markdown renderers to notebooks. This means that there are now two types of renderer inside a notebook's backing webview:
Output renderers are implemented using scripts rely on a global
acquireNotebookRendererApi
function:Markup renderers originally took the same approach, but we later switched them to use JS modules for a few reasons:
markdown-it
renderer is extended by another markup renderer that adds KaTeX supportnotebook.onDidCreateOutput
To power these two types of renderers, we also have two types of contribution points in extensions:
notebookOutputRenderers
andnotebookMarkupRenders
Goal
After working with and having to maintain these two separate renderer APIs, we believe it makes sense to unify them. A unified
renderer
API would let extension authors focus on rendering without having to worry about where the rendered output is used.We also think that the existing markup renderer api is nicer to work with and more future proof, so we'd like to move the existing APIs
Here's a summary of what we are trying to achieve:
Proposed design
Here's the current proposal for a unified renderer API. This would be the code implemented by an extension and loaded in the backlayer notebook webview. Note that while it looks quite long compared to the existing API, this is mainly because I've called out all the types involved. The actual code an extension would need to implement should only be a few lines longer than what you have to write today
Example implementation
#123738 adopts an early cut of this API for rendering markdown cells. The main files to look at:
markdownIt-renderer
— This is the top level markdown renderermarkdownIt-emoji-Renderer
— This shows how one renderer can extend another oneOpen questions
Should we try aligning kernel preloads with this API too?
May get complicated if you need to define globals
Should any parts of the api allow returning promises instead?
renderCell
for example?Should we block extensions from replacing our markdown renderer for markup cells?
For now, probably yes because tracking down why markdown rendering is weird would be difficult. Good to support in the future though
The text was updated successfully, but these errors were encountered: