-
Notifications
You must be signed in to change notification settings - Fork 8
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
Example of working through MyST port of the book #165
base: main
Are you sure you want to change the base?
Conversation
Thanks, @rowanc1! |
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.
A few callouts on the differences.
@@ -5,7 +5,6 @@ _nb_*/ | |||
*.blg | |||
*_bibertool.bib | |||
_bookdown.yml | |||
*.md |
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 probably need to read .rmd
but at this time only read .md
files.
plugins: | ||
- plugin.mjs |
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 are adding some plugins here in an mjs file!
import { fileError, liftChildren, NotebookCell } from 'myst-common'; | ||
import { remove } from 'unist-util-remove'; | ||
|
||
const MODE = 'python'; |
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.
This likely will be an env variable so that you can MODE = "python" && myst start
or similar.
const PYTHON_VARS = { | ||
lang: 'Python', | ||
np_or_r: 'NumPy', | ||
other_lang: 'R', |
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 are bringing this in to Javascript at the moment, but this could read from your existing variables, just being lazy to hack trhough a proof of concept.
const varShortCode = { | ||
name: 'var', | ||
body: { | ||
type: String, | ||
required: true, | ||
}, | ||
run(data, vfile) { | ||
const replacement = PYTHON_VARS[data.body]; | ||
if (!replacement) { | ||
fileError(vfile, `shortcode: "var", unknown replacement "${data.body}"`, { node: data.node }); | ||
return; | ||
} | ||
if (typeof replacement === 'string') { | ||
return [{ type: 'text', value: replacement }]; | ||
} | ||
return replacement; | ||
}, | ||
}; |
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.
This is the var
short code plugin. This requires a branch in mystmd, which adds some markup parsing.
```{r fig-round_ndigits_pl, opts.label='svg_fig', fig.cap="`round` with optional arguments specifying number of digits"} | ||
include_svg('diagrams/round_function_ndigits_pl.svg') | ||
```{figure} diagrams/round_function_ndigits_pl.svg | ||
:label: fig-round_ndigits_pl | ||
:width: 50% | ||
`round` with optional arguments specifying number of digits | ||
``` |
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.
This is the biggest change, these, as far as I can tell, are just figures?
We can apply the same operation on `q` to count the number of {{< var true | ||
>}} values. | ||
|
||
> }} values. |
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.
Hm, this is wrong, shouldn't be a blockquote!
::: {.callout-note} | ||
::: Python | ||
:::: {.callout-note} | ||
::: python |
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.
The :::
fence is treated a bit different. They need to be larger number of colons on the outside and they currently need to match the number on the closing of the fence.
:::::: | ||
:::: |
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.
This is again, a bit of a different treatment.
|
||
To do this, we make {{< var an_array >}} called `z` to hold the | ||
100 counts. We have called the {{< var array >}} `z`, but we could have | ||
100 counts. We have called the {{< var array >}} `z`, but we could have |
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.
Shortcodes work!
@stefanv the diff is very large at the moment. My formatter did some opinionated changes that I wasn't that careful about, I think the changes are actually quite small. I will make a review to call things out.
This is dependent on the branch in mystmd here:
https://github.com/executablebooks/mystmd/tree/feat/parser