Skip to content

Add support for 4 plainb formats#48

Merged
Yahiewi merged 16 commits into
notebook-link:mainfrom
Yahiewi:plainb
Jun 10, 2026
Merged

Add support for 4 plainb formats#48
Yahiewi merged 16 commits into
notebook-link:mainfrom
Yahiewi:plainb

Conversation

@Yahiewi

@Yahiewi Yahiewi commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

This PR addresses issue #46 by adding support for the 4 formats supported by jupyter-plainb:

Supported formats

Parser Menu label File type Format
parsePy Percent format (.py) .py Jupytext percent
parseSphinxGallery Sphinx Gallery (.py) .py Sphinx-Gallery
parseClassicMd Classic Markdown (.md) .md Standard markdown — fenced code blocks become code cells
parseMystMd MyST Notebook (.md) .md MyST-NB {code-cell} directives

I also added a plainb subdirectory under demo/files which contains the examples from jupyter-plainb.
This needs jupyter-plainb to be installed in the testing environment.
Similar to jupyter-plainb, Specta options are added to the "Open With" context menu.
Here is a screencast:

Screencast.from.2026-06-01.14-18-26.mp4

I'm not sure why the output cells in the specta view (dashboard mode I believe) are aligned to the left and I'm currently investigating it.
EDIT: This seems to be a general specta problem for which I opened issue #49

@trungleduc

Copy link
Copy Markdown
Collaborator

you need to update this https://github.com/notebook-link/specta/actions/runs/26754522649/job/78853130650#step:4:1211

@Yahiewi

Yahiewi commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @trungleduc CI is green now.

@trungleduc

Copy link
Copy Markdown
Collaborator

does this mean specta needs to depend on jupyter-plainb?

@Yahiewi

Yahiewi commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator Author

does this mean specta needs to depend on jupyter-plainb?

Only for this feature to work, otherwise if jupyter-plainb isn't installed nothing happens and specta works as usual.
It's also not a dependency as I didn't add it to the package.json, I only installed it using pip

@trungleduc

Copy link
Copy Markdown
Collaborator

hmm it does not sound practical since you need to know about jupyter-plainb to use this feature. How about adding plainb to packages.json and using the parser to convert the content directly in specta? So specta work without any external deps

@trungleduc

Copy link
Copy Markdown
Collaborator

and please verify if the stanalone specta app also works

@Yahiewi

Yahiewi commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

Hey @trungleduc I've made some changes to the plainb library by adding format detection in this PR and I used it in jupyter-plainb in this PR and now I also updated this PR to use it. The reason I made this change, is because in the standalone specta app, files open directly when clicking on them, so having the extension know what format a plaintext file is in, would allow it to use the correct parser.
Also as we no longer have jupyter-plainb installed like you asked, I created a new plainb_factory.ts which has code very similar to model.ts from jupyter-plainb.
Here is a demo in the standalone app:

Screencast.from.2026-06-03.14-27-06.mp4

@Yahiewi Yahiewi requested a review from trungleduc June 4, 2026 09:34

@trungleduc trungleduc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specta metadata still works with the plainb file?

Comment thread demo/jupyter-lite.json Outdated
Comment thread src/topbar/index.tsx Outdated
@Yahiewi

Yahiewi commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

The specta metadata still works with the plainb file?

Yes, I've added different specta metadata configurations for the 5 plain demo examples.

Here is a screencast of the examples being viewed in the Specta standalone app:

Screencast.from.2026-06-05.15-25-59.mp4

@Yahiewi Yahiewi requested a review from trungleduc June 5, 2026 13:27
Comment thread src/document/plugin.ts Outdated
? plainbFileType.name
: fileTypes[0]?.name;

if (PathExt.extname(path) === '.ipynb' || isPlainb) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks copy-pasted from previous block, could we refactor it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I refactored duplicated code into helper functions getSpectaDocInfo and openDocument in tool.ts

@Yahiewi Yahiewi merged commit 657e148 into notebook-link:main Jun 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants