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
Ability to Remove Clipboard for Code Snippets #2418
Comments
Use
Add .highlight.no-copy .md-clipboard { display: none; } In markdown_extensions:
- attr_list
extra_css:
- assets/css/custom.css |
Thanks, @polarathene – definitely the way to go! |
@polarathene Is there a particular version in which this is supported? I'm using 4.6.3 and am struggling to upgrade. When following your steps, I get the following results: |
With that said, now I need to check if Python Markdown's built-in |
@BrandonE Are you using it exactly as that? @facelessuser I tested with SuperFences enabled iirc. |
@polarathene, You used |
Yeah, I just tested. Lose the |
@facelessuser yes I used it exactly as shown above and I'm pretty certain it worked fine, so long as I provided the language class as mentioned (using pygments, haven't tested with highlight.js). |
@polarathene I don't know what you are doing, but that doesn't work.
|
Maybe you are not using SuperFences? 🤷 |
It's not a mistake, it is an exploit. I'm the author of the plugin, and I do not support I say all of this as the author of SuperFences. The space is not needed when using |
This also works, but it is not intentional:
It's just that we aren't strict about what is found between |
I was just referencing the Regardless, solution works as shown and @BrandonE should be able to get it working with the info above (with or without the |
It no longer shows this syntax in the result, but the clipboard is still visible: |
Using the text lexer should work:
|
Yup, the first class is assumed to be the language, so you need to specify a language if you specify additional classes. |
No luck @squidfunk @facelessuser: Unsure if this is helpful at all, but here are the HTML elements that are generated using the code that I previously posted. It looks like my version uses |
Please post your config. I'm having a hard time understanding what you have enabled for plugins. I at least can tell you are using CodeHilite, probably? |
mkdocs.yml: site_name: "Workbook"
site_description: "Workbook"
site_author: "..."
nav:
- Introduction:
- 'Home': 'index.md'
- 'System Requirements': 'labs/system_requirements/index.md'
- 'Errata Patches': 'errata/index.md'
- Exercises:
- "Lab 0": "labs/setup/index.md"
- Resources:
- "Troubleshooting": "troubleshooting/index.md"
- "References": "references/index.md"
extra_css:
- css/jquery.fancybox.min.css
- css/custom.css
- css/pdf.css
extra_javascript:
- js/jquery-3.4.1.min.js
- js/jquery.fancybox.min.js
- js/custom.js
theme:
name: 'material'
palette:
primary: 'Orange'
accent: 'Blue'
feature:
tabs: true
font: false
logo:
icon: 'home'
favicon: 'media/favicon.png'
markdown_extensions:
- admonition
- attr_list
- codehilite:
guess_lang: false
- toc:
permalink: false
toc_depth : "1-3"
- pymdownx.arithmatex
- pymdownx.betterem:
smart_enable: all
- pymdownx.caret
- pymdownx.critic
- pymdownx.details
- pymdownx.inlinehilite
- pymdownx.magiclink
- pymdownx.mark
- pymdownx.smartsymbols
- pymdownx.superfences
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.tilde
plugins:
- search
- exclude:
glob:
- "*.pdf"
- pdf-export:
verbose: false
combined: true
combined_output_path: pdf/Workbook.pdf
media_type: print
enabled_if_env: ENABLE_PDF_EXPORT requirements.txt:
|
Try updating Also, if you are using the latest |
@facelessuser Upgrading Afterwards, I get this error, which I understand means that I need to update my
I get the same problem if I remove the |
Yeah, you were on an older version. I'd check out the migration guide: https://squidfunk.github.io/mkdocs-material/upgrading/. I can't answer questions about the PDF plugin as I don't use it. |
If things are unclear, you can always reference other mkdocs.yml files that are using the most recent config format. Obviously, you can look at this projects yml, but you can also look at mine as well: https://github.com/facelessuser/pymdown-extensions/blob/main/mkdocs.yml. |
@facelessuser I was referring to the 4.x to 5.x migration process. I changed I removed the entire theme section, which resulted in
|
I can now see that this particular error is the same as this one: #1600 - I can now get mkdocs to serve again. Sorry for not properly following the migration documents; it can get confusing which part of the file I neglected to update when the error messages are hard to make sense of. Edit: The advice provided earlier for hiding the clipboard now works! Thanks! |
Yeah, this can be a little annoying that you can't always get sane errors when a configuration issue arises. I know when I migrated I ran into that same issue. |
@facelessuser from the comments, I read that |
Let me be clear,
It happens to work if you use a space just because how Is this a little confusing? Yup. In general, it is probably less confusing to just never use |
Thanks for the explanation! Fixed all occurrences in e9c5b53. |
Fixed in 128e267. As of Material for MkDocs 9, the copy-to-clipboard button will be opt-in. It can be enabled globally via a new feature flag called |
I want to suggest an idea and checked that ...
Description
I would like the ability to remove the "copy to clipboard" functionality for specific code snippets on a case-by-base basis.
Use Cases
I like to show a command that the viewer should run followed by the expected output. I use code snippets for both of these purposes. However, an inattentive viewer might confuse the command for the expected output and try to copy and paste the output. I would like to prevent this by hiding the clipboard icon for expected output.
Screenshots / Mockups
The syntax can look something like this:
The text was updated successfully, but these errors were encountered: