Skip to content

Commit

Permalink
Permit nested admonitions
Browse files Browse the repository at this point in the history
Use the documentations' language to nudge users away from doing this.
  • Loading branch information
pradyunsg committed Mar 3, 2021
1 parent 6255b45 commit 75d2eef
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
40 changes: 40 additions & 0 deletions docs/reference/admonitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,43 @@ Maaa! I made it look the same by setting the class.
```{todo}
Describe the CSS variables needed.
```

## Nesting admonitions


``````{furo-demo}
`````{note}
You can nest admonitions.
````{warning}
But you really should not.
```{danger}
It's distracting.
```
And can be confusing for the user to understand.
````
And, honestly, looks weird.
`````
+++
.. note::
You can nest admonitions.
.. warning::
But you really should not.
.. danger::
It's distracting.
And can be confusing for the user to understand.
And, honestly, looks weird.
``````
4 changes: 2 additions & 2 deletions src/furo/assets/styles/content/_admonitions.sass
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
@each $type, $value in $admonitions
&.#{$type}
border-left-color: var(--color-admonition-title--#{$type})
.admonition-title
> .admonition-title
background-color: var(--color-admonition-title-background--#{$type})
&::before
background-color: var(--color-admonition-title--#{$type})
mask-image: var(--icon-#{nth($value, 2)})

.admonition-todo .admonition-title
.admonition-todo > .admonition-title
text-transform: uppercase
16 changes: 8 additions & 8 deletions src/furo/sphinxext.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def _md_demo(block: str) -> StringList:
if not block.strip("\n"):
return StringList()

lines.append("`````{tab} Markdown (MyST)")
lines.append("````md")
lines.append("````````{tab} Markdown (MyST)")
lines.append("```````md")
lines.extend(block.splitlines())
lines.append("````")
lines.append("```````")
lines.extend(block.splitlines())
lines.append("`````")
lines.append("````````")

return StringList(lines)

Expand All @@ -54,15 +54,15 @@ def _rst_demo(block: str) -> StringList:
if not block.strip():
return StringList()

lines.append("`````{tab} reStructuredText")
lines.append("````{eval-rst}")
lines.append("````````{tab} reStructuredText")
lines.append("```````{eval-rst}")
lines.append(".. code-block:: rest")
lines.append("")
lines.extend(indent(block, " ").splitlines())
lines.append("")
lines.extend(block.splitlines())
lines.append("````")
lines.append("`````")
lines.append("```````")
lines.append("````````")

return StringList(lines)

Expand Down

0 comments on commit 75d2eef

Please sign in to comment.