orzih / mkdocs-with-pdf

Generate a single PDF file from MkDocs repository.
MIT License
333 stars 77 forks source link

use theme colors for pdf generation #119

Open DanielHabenicht opened 2 years ago

DanielHabenicht commented 2 years ago

The colors used for TOC and underlines of the headlines are currently statically set: image image

Instead of displaying the theme color inidigo-blue they use the colors set here: https://github.com/orzih/mkdocs-with-pdf/blob/f2e78d8c8ecb505636ba31a4830646038a78accd/mkdocs_with_pdf/styles/_heading.scss#L1-L12 https://github.com/orzih/mkdocs-with-pdf/blob/f2e78d8c8ecb505636ba31a4830646038a78accd/mkdocs_with_pdf/styles/_toc.scss#L42

It would be great if theses colors could either be specified in the plugin settings or use global defaults.

Workaround:

// Styling done by Material for Mkdocs: https://squidfunk.github.io/mkdocs-material/setup/changing-the-colors/#custom-colors
:root > * {
    --md-primary-fg-color: #e20074;
    --md-primary-fg-color--light: #ecb7b7;
    --md-primary-fg-color--dark: #9e0051;
}

#doc-toc * {
    border-color: var(--md-primary-fg-color) !important;
}

article h1,
article h2,
article h3 {
    border-color: var(--md-primary-fg-color)!important;
}
ojacques commented 2 years ago

@DanielHabenicht I know this is not the original request, but for the records, I was able to customize the color of the lines below the titles by adding a templates/styles.scss file with the following content:

$color: #004491;

@media print {

  .md-typeset h1 {border-bottom: 2px solid $color;  } // for material theme
  article h1 { border-bottom: 2px solid $color;  } // other theme

  .md-typeset h2 {border-bottom: 1px solid $color;  } // for material theme
  article h2 { border-bottom: 1px solid $color;  } // other theme

  .md-typeset h3 {border-bottom: 0.5px solid $color;  } // for material theme
  article h3 { border-bottom: 0.5px solid $color;  } // other theme

}
core-engineering commented 1 year ago

@ojacques

I don't know why but your solution doesn't work on my side. I have used the original workaround of @DanielHabenicht to customize the border-bottom color.