-
Notifications
You must be signed in to change notification settings - Fork 30
Enable MyST for use in info-view metadata section. #2116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@oliver-sanders - I'm a little concerned that MySTjs is quite primitive atm - See the list of features not available in mystjs at https://www.npmjs.com/package/mystjs#mystjs-features. I'm also concerned that we may need to supply our own CSS to make it render well: The code isn't well rendered, and the admonition and the maths aren't rendered at all. Inspection suggests that they have the correct classes for styling, but that there isn't any inline: Inserting some CSS into the markdown made the tip box look like a tip box, but I'm not sure that we should be responsible for that. |
Quoting from the link, these are the missing features:
These are all either HTML features or ReStructuredText features. MySt would appear to be feature complete for the common-mark specification. So I think this is pretty good.
Their examples render very nicely, see the sandbox - https://mystmd.org/sandbox From a quick search of the repo I found this CSS. You may need to link it into your HTML if using the JS library standalone: |
@wxtim, have you pulled through the MyST CSS in this PR? |
Not yet - drafting until I've worked it out. |
(unsubscribing) |
Manual Test, showing what is possible: The Workflow Definition[scheduling]
cycling mode = integer
[[graph]]
R1 = foo
[runtime]
[[foo]]
script = while true; do sleep 30; done
[[[meta]]]
title = "My Title"
description = """
# Every Single
some text
## Heading
some text
### Level
some text
#### Possible
some text
##### No
some text
###### Rêally
> A moose bit my sister once.
---
## New section
% This is a comment.
[Great Auk - link example](https://en.wikipedia.org/wiki/Great_Auk)

## Lists
1. First item
2. Second item
* Yellow Submarine
## Admonitions
:::{note}
B flat
:::
:::{warning}
Live without warning.
:::
:::{tip}
My hobby room
:::
:::{danger}
Mouse
:::
:::{caution}
Horses
:::
:::{admonition} My Admonition
:class: customadmonition
This is a custom admonition.
:::
## Maths
This math is a role, {math}`e=mc^2`, while this math is wrapped in dollar signs, $Ax=b$.
## Table
:::{list-table}
:header-rows: 1
* - Header 1
- Header 2
- Header 3
* - Row 1
- Row 1
- Row 1
* - Row 2
- Row 2
- Row 2
"""
Another Metadata Section = """
:::{note}
This is a note admonition.
:::
"""
How about some code blocks = """
:::{code-block} python
# Python
def foo():
return "bar"
:::
:::{code-block} bash
#!/bin/bash
# Bash
echo "Hello, World!"
:::
""" Note I've note made this an explicit test in the test battery because that woudl be testing the dependency. |
@oliver-sanders : Ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some example markdown that makes use of this to src\services\mock\json\infoView.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the myst-theme package provides CSS: https://github.com/jupyter-book/myst-theme/tree/main/styles
Can we just import this from there? We can always apply additional modifications if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that will work - a quick look at that library suggests that it doesn't really contain things like .admonition
which are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet they seem to have good support for admonitions on their website?
https://jupyter-book.github.io/myst-theme/?path=/docs/components-admonitions--docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jupyter-book is using myst-to-react
, which looks like it's different output to myst-to-html
. I can see if I can do that, but it sounds a bit wierd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent quite a while trying to address this as well as trying to get the maths parsing working - these threads seemed to hint at solutions, but I was unable to- get them working:
mathPlugin
adds.html
attribute to node, but seems to be ignored inmystToHast
jupyter-book/mystmd#859- How to use myst-parser in browser to generate html from myst markdown string? jupyter-book/mystmd#824
There was a suggestion that css could be included like this:
.use(rehypeDocument, {
css: ['myst.css', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css'],
js: ["https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js", "https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"],
script: `document.addEventListener("DOMContentLoaded", (event) => {
renderMathInElement(document.body, {
delimiters: [{
left: "$$",
right: "$$",
display: true
},
{
left: "$",
right: "$",
display: false
}
]
});
});`
})
But I haven't been able to make that work either.
5d2cfb5
to
ccf59de
Compare
(Needs deconflicting, and this:)
|
src/styles/cylc/_markdown.scss
Outdated
p, ul, ol { | ||
&:not(:last-child) { | ||
margin-bottom: 0.8em; | ||
} | ||
} | ||
ul, ol { | ||
padding-left: 24px; | ||
} | ||
.v-theme--light & code { | ||
background-color: rgba(0, 0, 0, 0.05); | ||
} | ||
.v-theme--dark & code { | ||
background-color: rgba(255, 255, 255, 0.1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could look at more carefully incorporating the old styling into the new, as it was chosen to ensure the limited Markdown we already had fits with Vuetify
Also replaces
markdown-it
with the more powerful packageMyST
.After offline discussion @oliver-sanders and I decided to try MyST because
Branch-specific checks
Security
I can't find a vast amount of info:
The default for CommonMark standard is to pass everything through (or at least that's what CommonMark.js does)
But this doesn't seem to be implemented by MyST.js, whose own rather limited docs suggest that only
<sub>
,<super>
and<abbr>
will do anything. Testing this out seems to suggest that these aren't parsed correctly!Check List
CONTRIBUTING.md
and added my name as a Code Contributor.setup.cfg
(andconda-environment.yml
if present).?.?.x
branch.