Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS for output hardcoded in theme_name.py #22

Closed
eloops opened this issue Nov 27, 2018 · 5 comments
Closed

CSS for output hardcoded in theme_name.py #22

eloops opened this issue Nov 27, 2018 · 5 comments

Comments

@eloops
Copy link

eloops commented Nov 27, 2018

Looking at the theme files, it looks like the CSS is hardcoded in there and there is no way to override it.

As most of the mkdocs CSS usually resides in ~/css/ it would be nice to be able to drop a CSS file in there and have it pick it up.

ie ~/css/mkdocs-pdf-material.css or something.

@eloops
Copy link
Author

eloops commented Nov 27, 2018

Okay, nevermind. I thought I had tested this and it hadn't worked. I placed a file with the CSS (as listed in readme.md) under ~/css and included it in the mkdocs.yml (extra_css section). Upon building the PDF's had the required styling.

@eloops eloops closed this as completed Nov 27, 2018
@shauser
Copy link
Collaborator

shauser commented Nov 27, 2018

I could add an option to disable the inclusion of the stylesheet though, which would help with its customization. The first version actually had you include the stylesheet in your code, but I wanted this to require no changes in user code. This would prevent any requirements for !important or very specific selectors.

@eloops
Copy link
Author

eloops commented Nov 27, 2018

I don't really understand your meaning here. Does the hardcoded stylesheet in material.py override the CSS in mkdocs?

I think the only loss from having an external CSS is the inability to add computed values to headers/footers (i.e. page numbers).

@shauser
Copy link
Collaborator

shauser commented Nov 27, 2018

The stylesheet is always included as the last stylesheet in the head, so if you want to override any of the options from the default stylesheet you need to have the selector more specific or use !important. Not sure the option would be worth it though, given the very simple workaround if you actually need to overwrite something.

@eloops
Copy link
Author

eloops commented Nov 27, 2018

Got it. Thanks for the great plugin! On an unrelated note, I've been trying to make a combined PDF that contains a bookmark/outline tree that mirrors the layout of mkdocs.yml.

zhaoterryy has a pretty good solution (as weasyprint allows to 'build' a PDF logically from code), but unfortunately because of how weasyprint allocates the bookmarks, the resulting outline tree is a mess.

It uses the header level tags to create the outlines, and when collating the individual pages together it makes a mess. I've managed to cobble something together myself (ripping code from mkdocs-pandoc and using PyPDF2), but it is far from ideal or elegant.

I know this should probably be its own issue, though I don't see any really good answers to making it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants