Skip to content

Commit be0a36d

Browse files
committed
Fixed highlighted lines adding blank lines when copying
1 parent 368cad0 commit be0a36d

File tree

7 files changed

+27
-22
lines changed

7 files changed

+27
-22
lines changed

material/assets/javascripts/bundle.adc5bf89.min.js renamed to material/assets/javascripts/bundle.9ab3d63a.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.adc5bf89.min.js.map renamed to material/assets/javascripts/bundle.9ab3d63a.min.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.052bca4c.min.css renamed to material/assets/stylesheets/main.edf004c2.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/stylesheets/main.052bca4c.min.css.map renamed to material/assets/stylesheets/main.edf004c2.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{% endif %}
3535
{% endblock %}
3636
{% block styles %}
37-
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.052bca4c.min.css' | url }}">
37+
<link rel="stylesheet" href="{{ 'assets/stylesheets/main.edf004c2.min.css' | url }}">
3838
{% if config.theme.palette %}
3939
{% set palette = config.theme.palette %}
4040
<link rel="stylesheet" href="{{ 'assets/stylesheets/palette.e6a45f82.min.css' | url }}">
@@ -213,7 +213,7 @@
213213
</script>
214214
{% endblock %}
215215
{% block scripts %}
216-
<script src="{{ 'assets/javascripts/bundle.adc5bf89.min.js' | url }}"></script>
216+
<script src="{{ 'assets/javascripts/bundle.9ab3d63a.min.js' | url }}"></script>
217217
{% for path in config["extra_javascript"] %}
218218
<script src="{{ path | url }}"></script>
219219
{% endfor %}

src/assets/javascripts/integrations/clipboard/index.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,14 @@ interface SetupOptions {
5252
/**
5353
* Extract text to copy
5454
*
55-
* This function hides annotations prior to extracting the text from the given
56-
* code block, so they're not included in the text that is copied to clipboard.
57-
*
5855
* @param el - HTML element
5956
*
6057
* @returns Extracted text
6158
*/
6259
function extract(el: HTMLElement): string {
63-
const annotations = getElements(".md-annotation", el)
64-
for (const annotation of annotations)
65-
annotation.hidden = true
66-
67-
/* Extract text and show annotations */
60+
el.setAttribute("data-md-copying", "")
6861
const text = el.innerText
69-
for (const annotation of annotations)
70-
annotation.hidden = false
71-
72-
/* Return extracted text */
62+
el.removeAttribute("data-md-copying")
7363
return text
7464
}
7565

src/assets/stylesheets/main/extensions/pymdownx/_highlight.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,21 @@
210210
position: absolute;
211211
visibility: hidden;
212212
}
213+
214+
// Copying in progress - this class is set before the content is copied and
215+
// removed after copying is done to mitigate whitespace-related issues.
216+
code[data-md-copying] {
217+
218+
// Remove highlighted lines - see https://bit.ly/32iVGWh
219+
.hll {
220+
display: contents;
221+
}
222+
223+
// Remove code annotation
224+
.md-annotation {
225+
display: none;
226+
}
227+
}
213228
}
214229

215230
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)