-
Notifications
You must be signed in to change notification settings - Fork 328
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
adding custom admonitions classes #183
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -428,15 +428,30 @@ Admonitions | |||||
|
||||||
You can make up your own admonition too. | ||||||
|
||||||
.. admonition:: If you add a name flag, it will be styled | ||||||
:name: warning | ||||||
.. admonition:: If you add a class flag, it will be styled | ||||||
:class: warning | ||||||
|
||||||
For example, this admonition block uses the following code: | ||||||
|
||||||
.. code-block:: | ||||||
|
||||||
.. admonition:: If you add a name flag, it will be styled | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
:name: warning | ||||||
:class: warning | ||||||
|
||||||
Here are a list of classes you can try: | ||||||
|
||||||
.. code-block:: | ||||||
|
||||||
note | ||||||
important | ||||||
tip | ||||||
attention | ||||||
caution | ||||||
warning | ||||||
danger | ||||||
error | ||||||
hint | ||||||
|
||||||
|
||||||
Topics, Sidebars, and Rubrics | ||||||
----------------------------- | ||||||
|
@@ -499,7 +514,7 @@ HTML | |||||
The HTML below shouldn't display, but it uses RequireJS to make sure that all | ||||||
works as expected. If the widgets don't show up, RequireJS may be broken. | ||||||
|
||||||
.. jupyter-execute:: | ||||||
.. jupyter-execute:: | ||||||
|
||||||
import plotly.io as pio | ||||||
import plotly.express as px | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,3 +110,160 @@ pre { | |
margin: 1.5em 0 1.5em 0; | ||
box-shadow: 1px 1px 1px #d8d8d8; | ||
} | ||
|
||
// Admonitions CSS inspired by https://squidfunk.github.io/mkdocs-material/getting-started/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe directly put this in a separate file |
||
$icon-info-circle: "\f05a"; | ||
$icon-exclamation-circle: "\f06a"; | ||
$icon-lightbulb: "\f0eb"; | ||
$icon-question: "\f128"; | ||
$icon-exclamation-triangle: "\f071"; | ||
$icon-times-circle: "\f057"; | ||
|
||
.admonition { | ||
margin: 1.5625em 0 !important; | ||
padding: 0 .6rem !important; | ||
overflow: hidden; | ||
page-break-inside: avoid; | ||
border-left: .2rem solid #448aff; | ||
border-radius: .1rem; | ||
box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,.05), 0 0 0.05rem rgba(0,0,0,.1); | ||
transition: color 250ms,background-color 250ms,border-color 250ms; | ||
|
||
// Last paragraph should have same spacing as title | ||
p:last-child { | ||
margin-bottom: 0.4em; | ||
} | ||
|
||
// Defaults for all admonitions | ||
.admonition-title { | ||
position: relative; | ||
margin: 0 -0.6rem !important; | ||
padding: .4rem .6rem .4rem 2rem; | ||
font-weight: 700; | ||
background-color: rgba(68,138,255,.1); | ||
|
||
&:before { | ||
position: absolute; | ||
left: .6rem; | ||
width: 1rem; | ||
height: 1rem; | ||
color: #448aff; | ||
font-family: "Font Awesome 5 Free"; | ||
font-weight: 900; | ||
content: $icon-info-circle; /* info-circle */ | ||
} | ||
|
||
// Next element after title needs some extra upper-space | ||
+ * { | ||
margin-top: 0.4em; | ||
} | ||
} | ||
|
||
&.attention { | ||
border-color: #f0b37e; | ||
.admonition-title { | ||
background-color: #ffedcc; | ||
|
||
&:before { | ||
color: #f0b37e; | ||
content: $icon-exclamation-circle; | ||
} | ||
} | ||
} | ||
|
||
&.caution { | ||
border-color: #f0b37e; | ||
.admonition-title { | ||
background-color: #ffedcc; | ||
|
||
&:before { | ||
color: #f0b37e; | ||
content: $icon-exclamation-triangle; | ||
} | ||
} | ||
} | ||
|
||
&.warning { | ||
border-color: #f29f97; | ||
.admonition-title { | ||
background-color: #fdf3f2; | ||
|
||
&:before { | ||
color: #f29f97; | ||
content: $icon-exclamation-triangle; | ||
} | ||
} | ||
} | ||
|
||
&.danger { | ||
border-color: #f29f97; | ||
.admonition-title { | ||
background-color: #fdf3f2; | ||
|
||
&:before { | ||
color: #f29f97; | ||
content: $icon-exclamation-triangle; | ||
} | ||
} | ||
} | ||
|
||
&.error { | ||
border-color: #f29f97; | ||
.admonition-title { | ||
background-color: #fdf3f2; | ||
|
||
&:before { | ||
color: #f29f97; | ||
content: $icon-times-circle; | ||
} | ||
} | ||
} | ||
|
||
&.hint { | ||
border-color: #1abc9c; | ||
.admonition-title { | ||
background-color: #dbfaf4; | ||
|
||
&:before { | ||
color: #1abc9c; | ||
content: $icon-lightbulb; | ||
} | ||
} | ||
} | ||
|
||
&.tip { | ||
border-color: #1abc9c; | ||
.admonition-title { | ||
background-color: #dbfaf4; | ||
|
||
&:before { | ||
color: #1abc9c; | ||
content: $icon-lightbulb; | ||
} | ||
} | ||
} | ||
|
||
&.important { | ||
border-color: #6ab0de; | ||
.admonition-title { | ||
background-color: #e7f2fa; | ||
|
||
&:before { | ||
color: #6ab0de; | ||
content: $icon-exclamation-circle; | ||
} | ||
} | ||
} | ||
|
||
&.note { | ||
border-color: #6ab0de; | ||
.admonition-title { | ||
background-color: #e7f2fa; | ||
|
||
&:before { | ||
color: #6ab0de; | ||
content: $icon-info-circle; | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 nice - we don't need to use our hacky extra code to achieve this effect now - this is functionality that "already works" in Sphinx