mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-24 07:30:12 +01:00
Fixed highlighted lines adding blank lines when copying
This commit is contained in:
parent
368cad0955
commit
be0a36d1b0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -34,7 +34,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.052bca4c.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.edf004c2.min.css' | url }}">
|
||||||
{% if config.theme.palette %}
|
{% if config.theme.palette %}
|
||||||
{% set palette = config.theme.palette %}
|
{% set palette = config.theme.palette %}
|
||||||
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
|
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
|
||||||
@ -213,7 +213,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.adc5bf89.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.9ab3d63a.min.js' | url }}"></script>
|
||||||
{% for path in config["extra_javascript"] %}
|
{% for path in config["extra_javascript"] %}
|
||||||
<script src="{{ path | url }}"></script>
|
<script src="{{ path | url }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -52,24 +52,14 @@ interface SetupOptions {
|
|||||||
/**
|
/**
|
||||||
* Extract text to copy
|
* Extract text to copy
|
||||||
*
|
*
|
||||||
* This function hides annotations prior to extracting the text from the given
|
|
||||||
* code block, so they're not included in the text that is copied to clipboard.
|
|
||||||
*
|
|
||||||
* @param el - HTML element
|
* @param el - HTML element
|
||||||
*
|
*
|
||||||
* @returns Extracted text
|
* @returns Extracted text
|
||||||
*/
|
*/
|
||||||
function extract(el: HTMLElement): string {
|
function extract(el: HTMLElement): string {
|
||||||
const annotations = getElements(".md-annotation", el)
|
el.setAttribute("data-md-copying", "")
|
||||||
for (const annotation of annotations)
|
|
||||||
annotation.hidden = true
|
|
||||||
|
|
||||||
/* Extract text and show annotations */
|
|
||||||
const text = el.innerText
|
const text = el.innerText
|
||||||
for (const annotation of annotations)
|
el.removeAttribute("data-md-copying")
|
||||||
annotation.hidden = false
|
|
||||||
|
|
||||||
/* Return extracted text */
|
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +210,21 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copying in progress - this class is set before the content is copied and
|
||||||
|
// removed after copying is done to mitigate whitespace-related issues.
|
||||||
|
code[data-md-copying] {
|
||||||
|
|
||||||
|
// Remove highlighted lines - see https://bit.ly/32iVGWh
|
||||||
|
.hll {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove code annotation
|
||||||
|
.md-annotation {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user