Skip to content

Commit

Permalink
Fix options
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed May 10, 2024
1 parent 1b7d79b commit 443161e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
22 changes: 11 additions & 11 deletions docs/admonitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ Try changing `tip` to `warning`!
:::
```

In MyST we call these kind of directives {myst:directive}`admonitions <admonition>`, however, they are almost always used through their _named_ directives, like `{note}` or `{danger}`. Admonitions can be styled as `simple` or as a `dropdown`, and can optionally hide the icon using the {myst:directive}`admonition.class` option. There are ten kinds[^docutils-admonitions] of admonitions available:
In MyST we call these kind of directives {myst:directive}`admonitions <admonition>`, however, they are almost always used through their _named_ directives, like {myst:directive}`note` or {myst:directive}`danger`. Admonitions can be styled as `simple` or as a `dropdown`, and can optionally hide the icon using the {myst:directive}`admonition.class` option. There are ten kinds[^docutils-admonitions] of admonitions available:

```{list-table} Named admonitions that can be used as directives
:label: admonitions-list
* - 🔵 `note`
- 🟠 `attention`
* - 🔵 `important`
- 🟠 `caution`
* - 🟢 `hint`
- 🟠 `warning`
* - 🟢 `seealso`
- 🔴 `danger`
* - 🟢 `tip`
- 🔴 `error`
* - 🔵 {myst:directive}`note`
- 🟠 {myst:directive}`attention`
* - 🔵 {myst:directive}`important`
- 🟠 {myst:directive}`caution`
* - 🟢 {myst:directive}`hint`
- 🟠 {myst:directive}`warning`
* - 🟢 {myst:directive}`seealso`
- 🔴 {myst:directive}`danger`
* - 🟢 {myst:directive}`tip`
- 🔴 {myst:directive}`error`
```

[^docutils-admonitions]: These admonitions are the same as those used in [docutils](https://docutils.sourceforge.io/docs/ref/rst/directives.html#specific-admonitions) and Sphinx.
Expand Down
10 changes: 8 additions & 2 deletions docs/directives.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ const mystDirectiveRole = {
const identifier = opt
? `directive-${directive?.name ?? name}-${opt}`
: `directive-${directive?.name ?? name}`;
const textToDisplay = modified?.trim() || `${name}.${opt}` || name;
var textToDisplay = modified?.trim() || name;
if (opt) {
textToDisplay = `${textToDisplay}.${opt}`;
}
return [
u('crossReference', { identifier }, [u('inlineCode', `{${textToDisplay}}`)]),
];
Expand All @@ -207,7 +210,10 @@ const mystRoleRole = {
const [name, opt] = label?.split('.') ?? [];
const role = defaultRoles.find((d) => d.name === name || d.alias?.includes(name));
const identifier = opt ? `role-${role?.name ?? name}-${opt}` : `role-${role?.name ?? name}`;
const textToDisplay = modified?.trim() || `${name}.${opt}` || name;
var textToDisplay = modified?.trim() || name;
if (opt) {
textToDisplay = `${textToDisplay}.${opt}`;
}
return [
u('crossReference', { identifier }, [u('inlineCode', `{${textToDisplay}}`)]),
];
Expand Down

0 comments on commit 443161e

Please sign in to comment.