Skip to content

Preview extension: Open file types other than notebook #1554

Description

@steovd

Problem

When used with Jupytext, Voila can be configured to render many different file types. However, the preview extension only allows notebooks. I can configure JupyterLab to open markdown in Voila preview by default, but it does not work, because the preview factory does not allow it.

{
  "@jupyterlab/docmanager-extension:plugin": {
    "defaultViewers": {
      "notebook": "Voila Preview"
    }
  }
}

fileTypes: ['notebook'],

Proposed Solution

Add markdown to the list of allowed file types.

Jupytext notebooks can also be saved as code. Other than listing all possible file types, which might have undesirable side effects, I'm not sure how to handle those formats. Perhaps look at how the Jupytext extension does it? Nonetheless, even if markdown was the only format added, it would be an improvement.

Additional context

As a workaround, I tried patching extension assets to add markdown to allowed file types, which does work.

grep -Fl '{name:"Voila Preview",fileTypes:["notebook"],modelName:"notebook"}' share/jupyter/labextensions/@voila-dashboards/jupyterlab-preview/static/*.js | xargs sed -i 's/name:"Voila Preview",fileTypes:\["notebook"\],modelName:"notebook"}/{name:"Voila Preview",fileTypes:\["notebook","markdown"\],modelName:"notebook"}/'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions