orzih / mkdocs-with-pdf

Generate a single PDF file from MkDocs repository.
MIT License
325 stars 76 forks source link

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

Open Valastiri opened 2 years ago

Valastiri commented 2 years ago

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.

fottsia commented 2 years ago

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

jacobswe commented 2 years ago

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

Valastiri commented 2 years ago

@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.

cmaurer commented 2 years ago

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;
    }

}
mudgen commented 2 years ago

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

santaimpersonator commented 1 year ago

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

Python packages:

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;
  }
}
nguyen-dhn commented 1 year ago

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:

brunocastroibarburu94 commented 1 year ago

Can confirm that @santaimpersonator worked for:

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"