jupyter-book / mystmd

Command line tools for working with MyST Markdown.
https://mystmd.org/guide
MIT License
203 stars 61 forks source link

Audit of Features missing in JupyterBook #189

Open rowanc1 opened 1 year ago

rowanc1 commented 1 year ago

Although mystmd and JupyterBook/sphinx are targeted at slightly different use-cases, there is overlap in creating websites (see background). Below is a list of missing features/directives/roles/ui that are not yet implemented in mystmd, we hope to have parity at the rendering level first, then move on to extensibility (see #181 as a major step).

We will try to keep this updated as we audit more jupyterbooks.

Directives

Roles

Config

Extensibility

See #181 as a roadmap.

Execution

Improvements

UI

URL:

Export

jan-david-fischbach commented 1 year ago

@rowanc1 To implement a feature on this list we need to simultaneously consider LaTeX and the Web output, correct? How could we go about sidebar/margin content? Using \minipage or similar does not really float my boat. At the moment I would be in favor of adding the sidebar content to the appendix, or to add it below the current paragraph as a content box. What do you think?

rowanc1 commented 1 year ago

It would certainly be appreciated to consider both html, latex and other exports, however, we can take contributions that get us there in a few iterations. The default falls back to rendering the child content, so it is just inline in the document. I think this might depend on what template you use and as you suggest, there isn't really a good default in latex!

If you are interested in implementing one of these features, can you open a specific issue on it? We can help give some guidance on where to look and how to get started!!

jan-david-fischbach commented 1 year ago

Maybe I'll find some time to work on the sidebar soon. Trying to come up with a workaround I noticed that html tags are not left unchanged: grafik

The myst-spec doesn't seem to say anything on how raw html is to be treated. The cheatsheet (which seems to be jb-flavoured myst) seems to indicate that html is interpreted as is.

Edit: It seems that one can set some allowDangerousHtml flag somewhere. I just don't know where yet

rowanc1 commented 1 year ago

I have opened and linked #516 with a few pointers to start, just ping me if you start working on it and get stuck and I can try to help out fast!

There is an outstanding bug for the HTML here:

It works fine when the round-trip is HTML (e.g. using the underlying js libraries), but our renderer is react, so we actually need the AST of the HTML correct, which is currently incorrect and not nested properly. For example, this AST of bold is [html, text, html] rather than [html > text] or converted to [strong > text] in this simple case. This is still going to be a bit of work to sort through.

jan-david-fischbach commented 1 year ago

Even with the "wrong" AST[^1] one seems to produce correct html with the allowDangerousHtml option:

import { u } from 'unist-builder';
import { mystToHtml } from 'myst-to-html';

let ast = u('root', [u('html', '<b>'), u('text', 'test'), u('html', '</b>')]);

const skewed_html = mystToHtml(ast);
console.log(skewed_html); // test

const html = mystToHtml(ast, {'hast': {'allowDangerousHtml': true}, 'stringifyHtml': {'allowDangerousHtml': true}});
console.log(html); // <b>test</b>

[^1]: The correct handling of html doesn't seem to be firmly defined: Does it all go into one html node, or using children for the content. How is markdown syntax inside html handeled etc.

rowanc1 commented 1 year ago

Yes, it will work for explicit HTML outputs which is string concatenation! However most of the tools are built on React, which operates on the AST and will try to create <b> as HTML, then 'test' text, then </b>. Which will end up with <b></b>test as the first node closes by default and the closing node isn't rendered. I think it is a bit worse actually as it looks like there is an extra paragraph, <b>test</b> turns into:

image

Not great, and something to fix up soon (#418)!