jupyter-book / mystmd

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

🍣 Add raw directives/roles for inserting tex/typst-specific content #1442

Closed fwkoch closed 1 month ago

fwkoch commented 1 month ago

This PR expands the raw node/role/directive behavior to allow tex- and typst-specific raw content that is only included in the respective export.

Currently, there is some existing raw functionality:

```{raw}
This inserts *raw* `unparsed` text in all contexts.
This allows you to use \textit{latex} in your markdown.
It will be \texttt{parsed} to MyST AST and included in all contexts.

(I feel like the latter is a little funny, since it says "raw" but it is parsing to AST... but that's ok for now.)

This PR adds `raw:latex` and `raw:typst` directives and roles that allow inserting typst and tex into your document that _only_ show up in their respective exports. So, for example, you can insert typst-specific formatting that is not required elsewhere:
#set page(columns: 2, margin: (x: 1.5cm, y: 2cm),);


The `{raw} latex` directive content is also now added directly into latex exports.
changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: e92c0c052c95cadcd8825ac9022cf26935e224b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages | Name | Type | | ---------------- | ----- | | myst-directives | Patch | | myst-spec-ext | Patch | | myst-to-typst | Patch | | myst-to-tex | Patch | | myst-roles | Patch | | myst-cli | Patch | | myst-common | Patch | | myst-config | Patch | | myst-frontmatter | Patch | | tex-to-myst | Patch | | myst-parser | Patch | | myst-to-html | Patch | | mystmd | Patch | | myst-transforms | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

rowanc1 commented 1 month ago

Nice - this does a good job at allowing us to pass through tex and typst directly to the templates. Super useful for some of the typst templates that we are doing in SciPy and other articles!