jupyterlab-myst icon indicating copy to clipboard operation
jupyterlab-myst copied to clipboard

Syntax extensions should be configurable

Open chrisjsewell opened this issue 3 years ago • 19 comments

As per https://myst-parser.readthedocs.io/en/latest/syntax/optional.html and https://github.com/executablebooks/myst-vs-code#preview-enhancement, all syntax extension should be configurable, to enable/disable. I don't think is possible yet @agoose77?

chrisjsewell avatar Jan 21 '22 14:01 chrisjsewell

It's currently possible to disable jupyterlab-markup extensions, with a checkbox:

image

These settings can also be set via the disabled-plugins property in the jupterlab-markup settings.

agoose77 avatar Jan 21 '22 14:01 agoose77

Ah ok cool 👍

chrisjsewell avatar Jan 21 '22 14:01 chrisjsewell

@chrisjsewell can this be closed?

agoose77 avatar Jan 25 '22 11:01 agoose77

yep, although at some point we should write a brief bit of documentation about how to use/configure the extension (in the README or better a small RTD site)

chrisjsewell avatar Jan 25 '22 11:01 chrisjsewell

Sounds good, let's leave this open then.

agoose77 avatar Jan 25 '22 11:01 agoose77

I think it doesn't work this way anymore? In jupyterlab==3.6.1 and jupyterlab_myst==1.1.1? There seems to be no way to toggle the syntax extensions.

tavin avatar Mar 02 '23 21:03 tavin

@tavin good spot; we upgraded the package, and lost some "features" along the way. The extensibility of MyST in general is something that the community at-large need to figure out. Although there is prior art for what this might look like, this fits into the wider context of what version of MyST (e.g. 2023.02.03) is in use, i.e. the need for a version identifier. We also want to make it convenient to extend the syntax of myst at the data-level, so that it can easily be adapted to particular use cases.

So, for now, watch this space.

agoose77 avatar Mar 02 '23 21:03 agoose77

Good to know @agoose77. Where in the code is the list of enabled extensions, for the sake of hacking on it locally?

tavin avatar Mar 02 '23 22:03 tavin

Some of the plugin configuration is here: https://github.com/executablebooks/jupyterlab-myst/blob/cc1ad5a61512c12084b83d61bdcc0ab57f45387b/src/myst.ts#L122-L131

agoose77 avatar Mar 02 '23 22:03 agoose77

And here for the roles/directives:

https://github.com/executablebooks/jupyterlab-myst/blob/main/src/myst.ts#L51-L54

rowanc1 avatar Mar 02 '23 22:03 rowanc1

Here's an idea about where to configure syntax extensions:

_config.yml
---
parse:
  myst_enable_extensions:

Maybe for this to work out, a user should somehow actively mark a directory as a "jupyter book project" or simply a "jupyter project" ...

tavin avatar Mar 18 '23 11:03 tavin

@agoose77 @rowanc1 I have a partial solution for this in #115. Through a labextension "token" I expose a simple interface that encapsulates the options object which is passed to the myst parser.

The currently hardcoded roles, directives, syntax extensions, etc. are kept as defaults.

It's relatively easy to write a labextension to alter these. You can imagine backing the interface with entries from the UI settings editor, or from notebook metadata, or whatever.

I've used this to implement a few custom directives as well.

For context and easy reference these are the options I'm talking about, which can be passed through the interface:

myst-parser/src/types.ts

export type AllOptions = {
  vfile: VFile;
  markdownit: MarkdownIt.Options;
  extensions: {
    colonFences?: boolean;
    frontmatter?: boolean;
    math?: boolean | MathExtensionOptions;
    footnotes?: boolean;
    deflist?: boolean;
    tasklist?: boolean;
    tables?: boolean;
    blocks?: boolean;
  };
  mdast: MdastOptions;
  directives: DirectiveSpec[];
  roles: RoleSpec[];
};

tavin avatar Mar 20 '23 21:03 tavin

This is super cool, still looking through the PR!

Do you have a demo of how to create a different lab extension to override the options?

rowanc1 avatar Mar 21 '23 17:03 rowanc1

@rowanc1 this is a fully working labextension which modifies the myst parser options: https://github.com/tavin/myst-options-poc/tree/main/src

tavin avatar Mar 26 '23 02:03 tavin

Hello, just wanted to add that this would be extremely helpful! I need a small number of additional directives from sphinx proof for my class materials, and writing would be much easier and cleaner if I could see these directives rendered in the notebook.

meldefon avatar Apr 26 '23 13:04 meldefon

Hi both @tavin and @meldefon -- I am hoping to get some time next week to come back to focusing on the extension. @agoose77 not sure if you have played with @tavin's proof of concept yet?

rowanc1 avatar Apr 26 '23 18:04 rowanc1

@meldefon we just added support for sphinx proof here: https://myst-tools.org/docs/mystjs/proofs-and-theorems Let us know what you think. An update should be coming soon to jupyterlab-myst to consume the new updates. Not a solve for this issue, but thought I would mention it since you are using that library!

rowanc1 avatar May 14 '23 19:05 rowanc1

This is fantastic!! Thank you very much. The editing experience is massively improved.

Sorry to keep demanding things, but I'm guessing that many of the users who need sphinx proof directives would also benefit from having sphinx exercise. Might be worth incorporating into the upcoming update.

meldefon avatar May 18 '23 15:05 meldefon

@meldefon added support for sphinx-exercise in https://github.com/executablebooks/mystjs/pull/399, this will be coming to jupyterlab soon after a few releases of the theme. 🚀

rowanc1 avatar May 28 '23 21:05 rowanc1