-
Notifications
You must be signed in to change notification settings - Fork 352
Fix display of mermaid diagrams in dark mode #2250
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
base: main
Are you sure you want to change the base?
Changes from all commits
fb4c81e
c6ff064
24d9478
09d3912
1ff66dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
======== | ||
Mermaid | ||
======== | ||
|
||
If you use `sphinxcontrib-mermaid <https://github.com/mgaitan/sphinxcontrib-mermaid>`_ | ||
to generate flowcharts or diagrams, and you output the diagrams in "raw" format, | ||
they will automatically adapt to this theme's light or dark mode. | ||
|
||
To use this feature, you'll need to install `sphinxcontrib-mermaid`_ and add it to your | ||
list of extensions in ``conf.py``: | ||
|
||
.. code-block:: python | ||
|
||
# conf.py | ||
extensions = [ | ||
..., | ||
"sphinxcontrib.mermaid", | ||
] | ||
|
||
This will enable the ``.. mermaid::`` directive. For example: | ||
|
||
.. begin-example-mermaid | ||
.. mermaid:: | ||
|
||
gitGraph: | ||
commit | ||
branch newbranch | ||
checkout newbranch | ||
commit id:"1111" | ||
commit tag:"test" | ||
checkout main | ||
commit type: HIGHLIGHT | ||
commit | ||
merge newbranch | ||
commit | ||
branch b2 | ||
commit | ||
.. end-example-mermaid | ||
|
||
is generated by the following code: | ||
|
||
.. include:: ./mermaid.rst | ||
:start-after: begin-example-mermaid | ||
:end-before: .. end-example-mermaid | ||
Comment on lines
+43
to
+44
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. Should these values both have a leading 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. first one doesn't need it, but it wouldn't hurt. Second one does need it. I tend to omit |
||
:code: rst | ||
:class: highlight | ||
|
||
See the `Mermaid documentation <https://mermaid.js.org/syntax/examples>`__ for additional examples. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* sphinxcontrib-mermaid | ||
* ref: https://github.com/mgaitan/sphinxcontrib-mermaid | ||
*/ | ||
|
||
/* Style the diagram such that it has a dark mode */ | ||
html[data-theme="dark"] pre.mermaid > svg { | ||
filter: brightness(0.8) invert(0.82) contrast(1.2); | ||
} |
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.
Do the over/underlines length need to exactly match the length of the title?
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.
no.