Open bollwyvl opened 9 years ago
I would guess the formatters should actually be registered with nbconvert, not nbviewer, right? I know we push back against setuptools, but if we want people to be able to register additional formatters, entry points are really the Python way to do it.
@takluyver, @ellisonbg, @fperez ?
I was looking at ipymd recently (really cool) and thought the same exact thing...
On Wed, May 13, 2015 at 10:13 PM, Min RK notifications@github.com wrote:
I would guess the formatters should actually be registered with nbconvert, not nbviewer, right? I know we push back against setuptools, but if we want people to be able to register additional formatters, entry points are really the Python way to do it.
@takluyver https://github.com/takluyver, @ellisonbg https://github.com/ellisonbg, @fperez https://github.com/fperez ?
— Reply to this email directly or view it on GitHub https://github.com/jupyter/nbviewer/issues/457#issuecomment-101915382.
Brian E. Granger Cal Poly State University, San Luis Obispo @ellisonbg on Twitter and GitHub bgranger@calpoly.edu and ellisonbg@gmail.com
I was also thinking nbconvert might want to make use of entry points. To that end, I'm working on a little package to discover entry points without using setuptools.
:)
Sent from my iPhone
On May 14, 2015, at 10:18 AM, Thomas Kluyver notifications@github.com wrote:
I was also thinking nbconvert might want to make use of entry points. To that end, I'm working on a little package to discover entry points without using setuptools.
— Reply to this email directly or view it on GitHub.
I agree nbconvert should be more easily extensible as well, but we'll always end up with some stuff specific to nbviewer, i think. URLs, icons, etc.
Ipymd is also great, in the way that yaml is great... As the best text editor experience for some structured data by a domain expert. In fact, i think some jekyll style front matter in --- --- would be an extremely good answer to "what is a cell"... It's once you want to add some meta data
Use Case
Enabling this use case is a good way to allow people to use notebooks off-the-shelf in their application without some of the security headaches of running full kernels. :warning: nbviewer runs arbitrary javascript. :warning:
At present, formats are not configurable. Following the pattern for providers, the existing formatters
html
&slides
should becomenbviewer.formats.html
andnbviewer.formats.slides
, and it should be easy (or at least pythonic) to author new plugins, enable and configure them, and disable existing ones.Proposal
Using
entry_points
, the workflow to add a new custom formatter such as above would be:implement a module
mymodule
myformatter.py
, a module that exposes some functions...nbconvert_template
label
icon
test
, whether a notebook should present the formatter: can look at the whole notebook json/stringpostprocess
, do something with anb, resources
bundle, like rewrite/strip thingsextra_template_paths
, getnbconvert_template
on the nbviewer template pathprovider_url_frag
, by default theentry_point
keyextra_static_paths
, in case you add branding... which is a whole other kettle of fish....setup.py
mymodule/templates/myformat.tpl
a new templatemymodule/static/some-image-script-or.css
maybe some new static stuff,MANIFEST.in
, for templates and staticmymodule
withsetup.py install/develop
python -m nbviewer --with-mykey
--switch
style configs, or #436, a traitleted config fileBlocked by #447.