jbms / sphinx-immaterial

Adaptation of the popular mkdocs-material material design theme to the sphinx documentation system
https://jbms.github.io/sphinx-immaterial/
Other
177 stars 28 forks source link

Line block does not preserve indent #272

Closed N-Wouda closed 11 months ago

N-Wouda commented 11 months ago

Hello, thanks for the great work on making this theme available to Sphinx users! I've recently moved over to using sphinx-immaterial and noticed that the line block markup does not preserve indent. This can be seen in the documentation: image I expect this to render as

image

like in the docutils example.

2bndy5 commented 11 months ago

I suspect this has something to do with the fact that we don't inherit CSS from a builtin sphinx theme... Looking at the docutils example, there's the following CSS rule:

div.line-block div.line-block {
  margin-left: 1.5em;
}

which provides the indent in HTML.

Digging into whatever else we're missing CSS-wise in the basic theme (a commonly inherited sphinx theme), I also see the following CSS rules:

.line-block {
  display: block;
  margin-top: 1em;
  margin-bottom: 1em;
}

.line-block .line-block {
  margin-top: 0;
  margin-bottom: 0;
  margin-left: 1.5em;
}

I don't think it would be harmful to other HTML elements if we add this CSS to our sphinx.scss file, but I would prefer a more specific selector (like div.line-block).

@N-Wouda Thanks for reporting this! Would you like to submit a PR with

  div.line-block {
    display: block;
  }

  div.line-block div.line-block {
    margin-left: 1.5em;
  }

added to our src/assets/stylesheets/main/_sphinx.scss file?

N-Wouda commented 11 months ago

Certainly! Thanks for investigating - I really wasn't sure where to begin. I'll open a PR in a minute!

2bndy5 commented 11 months ago

fix now available in v0.11.6

N-Wouda commented 11 months ago

Ah great! I'll update my use case to 0.11.6 right now. Let's hope for the best.

N-Wouda commented 11 months ago

Works beautifully: image

Thanks @2bndy5!