Skip to content

Commit

Permalink
Merge pull request #15 from executablebooks/fix/10/admonition-padding
Browse files Browse the repository at this point in the history
馃憣 IMPROVE: Make padding the same as admonitions
  • Loading branch information
najuzilu committed Oct 9, 2020
2 parents 5d5952a + fd7a454 commit aa5b459
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
48 changes: 48 additions & 0 deletions docs/source/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,51 @@ static int factorial(int n){
}
```
````


## How to Hide Directives

Directives can be hidden using the `dropdown` class which is available through [Sphinx Book Theme](https://sphinx-book-theme.readthedocs.io/en/latest/index.html). For Sphinx projects, add `"sphinx_book_theme"` to your `html_theme` in the `conf.py` to activate the theme in your Sphinx configuration

```md
...
html_theme = "sphinx_book_theme"
...
```

Jupyter Book's default theme is Sphinx Book Theme; therefore, Jupyter Book projects can utilize `dropdown` without having to activate the theme in your Sphinx configuration.


To hide the directive, simply add `:class: dropdown` as a directive option.

**Example**

```{exercise}
:class: dropdown
Recall that $n!$ is read as "$n$ factorial" and defined as
$n! = n \times (n - 1) \times \cdots \times 2 \times 1$.
There are functions to compute this in various modules, but let's
write our own version as an exercise.
In particular, write a function `factorial` such that `factorial(n)` returns $n!$
for any positive integer $n$.
```

**MyST Syntax**:

````
```{exercise}
:class: dropdown
Recall that $n!$ is read as "$n$ factorial" and defined as
$n! = n \times (n - 1) \times \cdots \times 2 \times 1$.
There are functions to compute this in various modules, but let's
write our own version as an exercise.
In particular, write a function `factorial` such that `factorial(n)` returns $n!$
for any positive integer $n$.
```
````
8 changes: 0 additions & 8 deletions sphinx_exercise/_static/exercise.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ div.exercise p.admonition-title {
background-color: var(--note-title-color);
}

div.exercise div.section {
padding: .6rem 1rem;
}

/* Remove content box */
div.exercise p.admonition-title::before {
content: none;
Expand All @@ -51,10 +47,6 @@ div.solution p.admonition-title a {
color: #333 !important;
}

div.solution div.section {
padding: .6rem 1rem;
}

/* Remove content box */
div.solution p.admonition-title::before {
content: none;
Expand Down

0 comments on commit aa5b459

Please sign in to comment.