Giter Site home page Giter Site logo

Comments (5)

majkinetor avatar majkinetor commented on June 12, 2024 1

I'm not sure I understand why you didn't have it.. print-site should add the CSS by default for you.

Because I have include_css: false. I have it because I needed this:

@media print {
    #print-site-banner {
        display: none;
    }
}

.nav-section-title-end,
.nav-section-title,
.toc-nav-section-title-level-2,
.toc-nav-section-title-level-3,
.toc-nav-section-title-level-4 {
    display: none;
}    

add_print_site_banner for some reason didn't work for me back when I used this, and other things are just something I needed for my particular case.

You can't return early

I suspected that, but wanted to ask anyway in case I missed something.

Thanks a lot for the answers. Everything is working perfectly now.

from mkdocs-print-site-plugin.

timvink avatar timvink commented on June 12, 2024

Indeed, that should work. Here's the CSS that should be injected:

/* Be able to not print certain elements */
#print-site-page .print-site-plugin-ignore { display: none;}
@media print {
/* included bookmarks on h1 and h2
Doesn't work, but included In case Chrome gets support
for these experimental CSS features that define PDF bookmarks */
/* #print-site-page h1 {
bookmark-level: 1;
bookmark-label: content();
-ah-bookmark-level: 1;
-ro-pdf-bookmark-level: 1;
}
#print-site-page h2 {
bookmark-level: 2;
bookmark-label: content();
-ah-bookmark-level: 2;
-ro-pdf-bookmark-level: 2;
} */
/* Be able to not print certain elements */
.print-site-plugin-ignore { display: none; }

The class should make sure the content is not displayed on the HTML print page, and not displayed when you print a page.

Some things I should investigate:

It might be that the CSS hierarchy is not working in this bit:

/* Be able to not print certain elements */
#print-site-page .print-site-plugin-ignore { display: none;}

Could also be that the CSS injection is not working properly.

Lastly, there could be conflicting HTML. Perhaps I should add !important to the CSS classes to make sure they override other styling.

from mkdocs-print-site-plugin.

timvink avatar timvink commented on June 12, 2024

I tested locally and can exclude the first two, seems to be working alright.

Do you have a live example I can see?

from mkdocs-print-site-plugin.

majkinetor avatar majkinetor commented on June 12, 2024

Yeah, it works with this CSS you provided. I didn't have it. Thank you.

Regarding the other question, do you have a comment on it ?

BTW, I want to ignore generated parts of the page which I inject via python function via plugin macros. I am having this function call in footer of page:

{{ include( page, 'txt', 'Primer podataka', '.print-site-plugin-ignore') }}

As an alternative to adding the class, is there any way I can return from this function early if I detect the page is being rendered by the print site ?

from mkdocs-print-site-plugin.

timvink avatar timvink commented on June 12, 2024

Yeah, it works with this CSS you provided. I didn't have it. Thank you.

I'm not sure I understand why you didn't have it.. print-site should add the CSS by default for you. Perhaps that was not working for you, could be because of a path issue from the plugin..

As an alternative to adding the class, is there any way I can return from this function early if I detect the page is being rendered by the print site ?

You can't return early. the print site is mostly an on_post_build step, that needs all the completed pages and then combines them into an additional, separate single page. The function from mkdocs-macros would still only be called once.

from mkdocs-print-site-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.