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

The content of the comment section and feedback should not be included when printing #7615

Closed
4 tasks done
Xiaokang2022 opened this issue Oct 13, 2024 · 5 comments
Closed
4 tasks done
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@Xiaokang2022
Copy link

Context

Python: 3.13.0
OS: Windows11 23H2

Bug description

When using the print function on some browsers, the comment and feedback areas at the bottom of the article will be printed together, but it should only contain the content of the article itself, not comments and feedback.

Related links

Reproduction

Unable to create .zip file:

Because the comment section needs to be customized to do so, but the plugin info doesn't allow that.

Here are some examples of information that may be useful:

  • Directory structure:
├─docs
│   └─index.md
├─override
│   └─partials
│       └─comments.html
└─mkdocs.yml
  • mkdocs.yml:
site_name: My Docs

markdown_extensions:
  - meta

theme:
  name: material
  custom_dir: override

plugins:
  - info
  • index.md:
---
comments: true
---
  • comments.html: (Here I replace some personal information with ... finish)
{% if page.meta.comments %}
<script src="https://giscus.app/client.js" data-repo="..." data-repo-id="..."
    data-category="GitHub Pages" data-category-id="..." data-mapping="pathname" data-strict="1"
    data-reactions-enabled="1" data-emit-metadata="0" data-input-position="top" data-theme="preferred_color_scheme"
    data-lang="zh-CN" data-loading="lazy" crossorigin="anonymous" async>
    </script>

<!-- Synchronize Giscus theme with palette -->
<script>
    var giscus = document.querySelector("script[src*=giscus]")

    // Set palette on initial load
    var palette = __md_get("__palette")
    if (palette && typeof palette.color === "object") {
        var theme = palette.color.scheme === "slate"
            ? "dark"
            : "light"

        // Instruct Giscus to set theme
        giscus.setAttribute("data-theme", theme)
    }

    // Register event handlers after documented loaded
    document.addEventListener("DOMContentLoaded", function () {
        var ref = document.querySelector("[data-md-component=palette]")
        ref.addEventListener("change", function () {
            var palette = __md_get("__palette")
            if (palette && typeof palette.color === "object") {
                var theme = palette.color.scheme === "slate"
                    ? "dark"
                    : "light"

                // Instruct Giscus to change theme
                var frame = document.querySelector(".giscus-frame")
                frame.contentWindow.postMessage(
                    { giscus: { setConfig: { theme } } },
                    "https://giscus.app"
                )
            }
        })
    })
</script>
{% endif %}

Steps to reproduce

Use browser's built-in print function on any page that contains a comment or feedback area.

Browser

Edge

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting. I agree that comments should be hidden. Fixed in 39d14d5.

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open labels Oct 14, 2024
@Xiaokang2022
Copy link
Author

Let me make sure that the feedback area also doesn't need to be displayed when printing, right?

@squidfunk
Copy link
Owner

Ah wait, forgot the feedback area 🙈

@squidfunk
Copy link
Owner

Fixed in e29e124.

@squidfunk
Copy link
Owner

Released as part of 9.5.41.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants