Skip to content

Conversation

choldgraf
Copy link
Collaborator

@choldgraf choldgraf commented Mar 14, 2020

This adds a special case to the "notes/warn/etc" admonition handling.

Admonitions are different because users can specify their own titles. This PR:

  • Uses the "note" admonition class by default
  • Updates the admonitiontitles dictionary on-the-fly to make it use the user-provided title
  • Then makes the admonition behave like any other admonition

This also makes it possible to style the admonition output using the :name: flag, so you can do things like

.. admonition: my title
   :name: warning

   A warning-styled admonition

See the end of the admonitions section here: https://176-130237506-gh.circle-artifacts.com/0/html/demo/demo.html#admonitions

For comparison, note the admonition at the end in the docs is not styled:
https://pandas-sphinx-theme.readthedocs.io/en/latest/demo/demo.html#admonitions

closes #117 and #70

@choldgraf
Copy link
Collaborator Author

@jorisvandenbossche can I get a review on this one? Currently if people use a generic admonition then there's no styling applied...

@jorisvandenbossche
Copy link
Member

Hmm, the preview is not loading.
I am not very familiar with custom admonitions. For my education, does the text you put after .. admonition:: then the title?

@choldgraf
Copy link
Collaborator Author

Yep, basically "notes" and "warnings" are just special cases of an admonition. So with the admonition directive you can define custom titles

@jorisvandenbossche jorisvandenbossche changed the title adding admonition special case Fix admonition special case (custom named admonition) Apr 11, 2020
@jorisvandenbossche jorisvandenbossche merged commit c776093 into pydata:master Apr 11, 2020
@jorisvandenbossche
Copy link
Member

OK, thanks!

@chipbrock
Copy link

chipbrock commented Jul 13, 2021

Is it possible to style the text formatting within an admonition? I would like for it to be serif so as to be more distinct from the standard sans-serif body font. It seems to inherit from <p>which makes this undoable with my limited css skills.

I can change the formatting of the admonition title (?) in my own css file...but not the body.

This, BTW, is for JupyterBooks that I'm trying to accomplish this. I'd greatly appreciate help with this. thanks.

@jorisvandenbossche
Copy link
Member

@chipbrock late reply, but I think that should still be possible by only selecting <p> tags that are inside the admonition div. For example the followins makes all text in the admonition title and body serif:

.admonition p {
 font-family:serif;
}

@jorisvandenbossche
Copy link
Member

Ah, I see you also opened #431 about this and there is some discussion there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admonitions aren't styled

3 participants