From b8f785fc4f524fdbc66517faca93da322b59cbda Mon Sep 17 00:00:00 2001 From: Iwan Date: Wed, 26 Feb 2020 11:46:52 +0100 Subject: [PATCH] Use innerText instead of textContent To avoid copying styles and scripts, this makes it work with the sphinx-prompt extension. https://www.w3schools.com/jsref/prop_node_innertext.asp I hacked it like this in my conf.py file for now: ``` copybutton_prompt_text = """>>> '; textContent = target.innerText.split('\\n'); var dummy = ' """ ``` --- sphinx_copybutton/_static/copybutton.js_t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_copybutton/_static/copybutton.js_t b/sphinx_copybutton/_static/copybutton.js_t index e91c792..522ce50 100644 --- a/sphinx_copybutton/_static/copybutton.js_t +++ b/sphinx_copybutton/_static/copybutton.js_t @@ -64,7 +64,7 @@ const temporarilyChangeTooltip = (el, newText) => { // should then grab the text and replace pieces of text that shouldn't be used in output var copyTargetText = (trigger) => { var target = document.querySelector(trigger.attributes['data-clipboard-target'].value); - var textContent = target.textContent.split('\n'); + var textContent = target.innerText.split('\n'); var copybuttonPromptText = '{{ copybutton_prompt_text }}'; // Inserted from config var onlyCopyPromptLines = {{ copybutton_only_copy_prompt_lines | lower }}; // Inserted from config var removePrompts = {{ copybutton_remove_prompts | lower }}; // Inserted from config