Prototype Allowing Extensions to Extend the Builtin Markdown Extension#22421
Prototype Allowing Extensions to Extend the Builtin Markdown Extension#22421mjbvz merged 4 commits intomicrosoft:masterfrom
Conversation
|
@mjbvz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @joaomoreno and @jrieken to be potential reviewers. |
|
Nice problem. The idea of the push model is surfaces in the fact that an extension can return its API from its The pull model on the other hand looks simpler but also less powerful. Also, I am not sure if you can add more intelli-sense help to the package.json. Tho @aeschli will know |
2757003 to
ce8baef
Compare
|
I've switched over to use the pull model, with the markdown extension exposing an API that other extensions can invoke. I also added an example extension that adds emoji support for markdown to show how this API works |
|
I'd prefer the original approach with the contributes section. I know we have the API to access other extensions, but going that approach has some problems:
|
**Problem**
There have been requests for adding new functionality to the markdown extension preview, such as supporting rendering of math or other syntax in the preview. The only current solution to this is create an extension that provides its own markdown preview. This results in inconsitent behavior with our markdown preview and is not a very scalable approach. We would like to find a way to allow users to add these extensions to our markdown preview without bundling the extensions in the preview itself.
**Fix**
Prototypes a new contribution point that extensions can use to extend the vscode markdown extension. Three types of extensions are possible: adding stypes to the preview, adding scripts to the preview, and extending the markdown it renderer.
My current approach defines the contributed markdown extensions in the package.json using a structure like this:
```
"contributesTo": {
"vscode.markdown": {
"plugins": [
"./out/math"
],
"scripts": [],
"styles": [
"./media/math.css"
]
}
}
```
We could change the structure here. This design uses a pull model where markdown extensions are looked up by the vscode.markdown extension itself.
The other approach for extension registration would be to use a push model. This would have the vscode.markdown extension export an api that each markdown extension would invoke to register new scripts/styles/plugins. I may switch over to this model but was interested in seeing what a more declarative approach would look like. Let me know if you have any thoughts one way or the other.
The downside of allowing extensions like this is that they can completely change how the markdown preview looks and works. There is no well defined API for restricting what extensions can do like we have with VScode.
ce8baef to
d090c04
Compare
|
Thanks @aeschli. We discussed the benefits of either approach a little more at our Tuesday sitdown and ultimately came out slightly more in favor of using the API based approach. The main reason is that this fits into our existing extension model and it means we can treat these markdown extensions just like we would any other extension. As for the two issue you bring up, take a look at the most recent change: it adds a new internal Just talked with @kieferrm and we're going to check in this work in it's current state so that extension developers can start playing around with it. I've added a undocumented Again, nothing is set in stone yet but using the extension API seems like the most promising approach at the moment. As always, please share any additional feedback or concerns that you have about the current approach and let me know if you feel something could be improved |
|
Neat trick with the command. You just need to hope that no one else calls that command :-) |
|
Hey @aeschli and @jrieken, after playing around with this prototype I've put together a new proposal for markdown extensions: https://github.com/mjbvz/vscode-markdown-emoji#api-proposal-take-two-not-yet-implemented Take a look and let me know if you have any concerns or suggestions here. It combines some aspects of each of the original prototypes |
Update
Switched over to use the pull model with the markdown extension exposing an API that other extensions can invoke. Also added an example extension to show how this API would work
Problem
There have been requests for adding new functionality to the markdown extension preview, such as supporting rendering of math or other syntax in the preview. The only current solution to this is create an extension that provides its own markdown preview. This results in inconsitent behavior with our markdown preview and is not a very scalable approach. We would like to find a way to allow users to add these extensions to our markdown preview without bundling lots of additional packages with vscode
Fix
Prototypes a new contribution point that extensions can use to extend the vscode markdown extension. Three types of extensions are possible: adding stypes to the preview, adding scripts to the preview, and extending the markdown it renderer.
My current approach defines the contributed markdown extensions in the package.json using a structure like this:
We could change the structure here. This design uses a pull model where markdown extensions are looked up by the vscode.markdown extension itself.
The other approach for extension registration would be to use a push model. This would have the vscode.markdown extension export an api that each markdown extension would invoke to register new scripts/styles/plugins. I may switch over to this model but was interested in seeing what a more declarative approach would look like. Let me know if you have any thoughts one way or the other.
The downside of allowing extensions like this is that they can completely change how the markdown preview looks and works. There is no well defined API for restricting what markdown extensions can do