orzih / mkdocs-with-pdf

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

custom admonition type in PDF #61

Open cooper-lzy opened 3 years ago

cooper-lzy commented 3 years ago

The custom admonition type in PDF cannot be displayed, only the default style is displayed. Please instruct me how to set it? image image

orzih commented 3 years ago

Hi @cooper-lzy.

Now, mkdocs-material generates style is:

.md-typeset .note>summary:before {
  background-color: #448aff;
  mask-image: var(--md-admonition-icon--note);
  ...
}

But, WeasyPrint not supports mask-image. This plugin set custom css.

To customize the icon, you need to set it yourself in your styles, e.g:

@media print
.md-typeset .note > .admonition-title::before, .md-typeset .note > summary::before {
    background-image:  url("data:image/svg+xml;charset=utf8,%3Csvg viewBox=....") !important;
}

See this polyfill:

https://github.com/orzih/mkdocs-with-pdf/blob/65f36ba383b022627df54db00d885d9e06dedd09/custum_style_src/material-polyfills/src/stylesheets/extensions/_admonition.scss#L62-L76