|
1 | 1 | /* Add an edit in repl link to code blocks */ |
2 | 2 |
|
3 | 3 | function checkForReplLinks() { |
4 | | - const replCode = document.querySelectorAll('pre'); |
5 | | - [...replCode].forEach(pre => { |
6 | | - console.log(pre); |
7 | | - const text = encodeURI(pre.innerText); |
| 4 | + // const replCode = document.querySelectorAll('pre'); |
| 5 | + // [...replCode].forEach(pre => { |
| 6 | + // console.log(pre); |
| 7 | + // const text = encodeURI(pre.innerText); |
| 8 | + // const link = document.createElement('a'); |
| 9 | + // link.title = 'Run this code in the REPL'; |
| 10 | + // link.innerText = 'Run this code in the REPL'; |
| 11 | + // link.href = '/repl/?code=' + text; |
| 12 | + // const paragraph = document.createElement('p'); |
| 13 | + // paragraph.appendChild(link); |
| 14 | + // const wrapper = document.createElement('div'); |
| 15 | + // pre.parentNode.insertBefore(wrapper, pre); |
| 16 | + // wrapper.appendChild(pre); |
| 17 | + // wrapper.appendChild(paragraph); |
| 18 | + // }); |
| 19 | + const replCode = document.querySelectorAll('.repl-code'); |
| 20 | + [...replCode].forEach(code => { |
| 21 | + const codeText = encodeURI(code.innerText); |
8 | 22 | const link = document.createElement('a'); |
9 | 23 | link.title = 'Run this code in the REPL'; |
10 | 24 | link.innerText = 'Run this code in the REPL'; |
11 | | - link.href = '/repl/?code=' + text; |
| 25 | + link.href = '/repl/?code=' + codeText; |
12 | 26 | const paragraph = document.createElement('p'); |
13 | 27 | paragraph.appendChild(link); |
14 | | - const wrapper = document.createElement('div'); |
15 | | - pre.parentNode.insertBefore(wrapper, pre); |
16 | | - wrapper.appendChild(pre); |
17 | | - wrapper.appendChild(paragraph); |
| 28 | + code.appendChild(paragraph); |
18 | 29 | }); |
19 | 30 | } |
20 | 31 |
|
|
0 commit comments