Added documentation for code copy button

This commit is contained in:
squidfunk 2023-01-02 14:29:16 +01:00
parent 3311c82cb5
commit 050bda6609
3 changed files with 47 additions and 1 deletions

View File

@ -42,6 +42,45 @@ See additional configuration options:
[SuperFences]: ../setup/extensions/python-markdown-extensions.md#superfences
[Snippets]: ../setup/extensions/python-markdown-extensions.md#snippets
### Code copy button
[:octicons-tag-24: 9.0.0][Code copy button support] ·
:octicons-unlock-24: Feature flag
Code blocks can automatically render a button on the right side to allow the
user to copy a code block's contents to the clipboard. Add the following to
`mkdocs.yml` to enable them globally:
``` yaml
theme:
features:
- content.code.copy
```
[Code copy button support]: https://github.com/squidfunk/mkdocs-material/releases/tag/9.0.0
??? info "Enabling or disabling code copy buttons for a specific code block"
If you don't want to enable code copy buttons globally, you can enable them
for a specific code block by using a slightly different syntax based on the
[Attribute Lists] extension:
```` yaml
``` { .yaml .copy }
# Code block content
```
````
Note that the language shortcode which has to come first must now also be
prefixed by a `.`. Similarily, the copy button can also be disabled for a
specific code block:
```` { .yaml .no-copy }
``` { .yaml .no-copy }
# Code block content
```
````
### Code annotations
[:octicons-tag-24: 8.0.0][Code annotations support] ·

View File

@ -51,7 +51,7 @@ theme:
Now, tooltips will be rendered for the following elements:
- __Content__ elements with a `title`, permalinks and copy-to-clipboard button
- __Content__ elements with a `title`, permalinks and code copy button
- __Header__ home button, header title, color palette switch and repository link
- __Navigation__ links that are shortened with ellipsis, i.e. `...`

View File

@ -587,6 +587,13 @@
"content.code.annotate"
]
},
{
"title": "Code copy button",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#code-copy-button",
"enum": [
"content.code.copy"
]
},
{
"title": "Linked content tabs",
"markdownDescription": "https://squidfunk.github.io/mkdocs-material/reference/content-tabs/#linked-content-tabs",