mkdocs-with-pdf icon indicating copy to clipboard operation
mkdocs-with-pdf copied to clipboard

Admonitions do not render in PDF output - mkdocs-material v8.0.2

Open Valastiri opened this issue 3 years ago • 9 comments
trafficstars

When building a PDF with version 8.0.2 from mk-material the output of the admonitions markdown extension is broken.

Sample from v7.3.6 image

Sample with v8.0.2 image

No existing changes were made to any configs beyond updating material version.

Valastiri avatar Nov 30 '21 21:11 Valastiri

We're facing the same issue, so currently we have to downgrade mkdocs-material every time we build the .pdf.

fottsia avatar Dec 05 '21 15:12 fottsia

Any progress on this? I am holding off on upgrading until we have some sort of fix for this

jacobswe avatar Dec 16 '21 16:12 jacobswe

@jacobswe I think it's just best to run on an older build for the pdf export and setup a special case *.yml. I was planning on doing this for the repo I maintain just haven't gotten around to it due to lists being a bit wonky.

Valastiri avatar Dec 26 '21 18:12 Valastiri

This appears to be a css issue. I was able to get decent looking admonitions by overriding the css with extra_sass.

Pipefile

libsass = "*"

mkdocs.yml

plugins:
  - extra-sass

extra_sass/style.css.scss

@media print {
    // admonition overrides

    // admonition icon
    .md-typeset :is(.admonition-title,summary):before {
      top: 0.6rem;
      left: 0.6rem;
    }

    // left border
    .md-typeset :is(.admonition,details) {
      border-left-width: 0.1rem;
      padding: 0rem 0rem 0rem 0rem;
      margin-left: 1rem;
    }

    [dir=ltr] .md-typeset :is(.admonition,details) {
      margin-left: 1rem;
    }

    html .md-typeset :is(.admonition,details)>:last-child {
      margin-left: 0.6rem;
    }

}

cmaurer avatar Aug 18 '22 13:08 cmaurer

@cmaurer I made the same changes you did but none of the styling show for my admonitions in the PDF. What am I missing?

mudgen avatar Sep 03 '22 03:09 mudgen

@mudgen I followed @cmaurer's comment, with a few modifications. I got the following result: image

Python packages:

  • mkdocs-material 8.5.7
  • mkdocs-with-pdf 0.9.3

mkdocs.yml

extra_css:
  - stylesheets/extra.css

docs/stylesheets/extra.css

@media print {
  /* Adjusts positioning of admonition icon */
  .md-typeset :is(.admonition-title,summary):before {
    top: 0.6rem;
    left: 0.6rem;
  }
}

santaimpersonator avatar Nov 16 '22 22:11 santaimpersonator

I've tried to combine the work of @cmaurer and @santaimpersonator but I still got the alignment issue as #135. Any ideas?

My environment: MacOS M1 Ventura 13.1 (Beta) with Python 3.10.6 (use Conda as package management system).

My package's version:

  • mkdocs-material 8.5.7
  • mkdocs-with-pdf 0.9.3
  • mkdocs 1.4.2 / 1.4.1

nguyen-dhn avatar Dec 03 '22 15:12 nguyen-dhn

Can confirm that @santaimpersonator worked for:

  • mkdocs-material==8.5.10
  • mkdocs-with-pdf==0.9.3
  • mkdocs==1.4.2

Using a docker image adapted from python:3.9.8

It is worth double checking the mkdocs.yml file and the references to the files "extra.css" and "style.css.scss"

brunocastroibarburu94 avatar Jan 22 '23 23:01 brunocastroibarburu94