Skip to content

Commit 1c3119a

Browse files
committed
Add special characters inside their generated spans so find and replace counts them (Fixes #154).
1 parent 3aeb959 commit 1c3119a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

plugins/special-chars.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
vertical-align: middle;
3838
outline: 0.1px solid currentColor;
3939

40+
/* Contain character for use by other plugins, but hide it */
41+
color: transparent;
42+
font-size: 0;
43+
4044
--hex-0: var(
4145
--code-input_special-chars_0);
4246
--hex-1: var(
@@ -91,4 +95,4 @@
9195
height: 1.5em;
9296
bottom: -1em;
9397
content: attr(data-hex3);
94-
}
98+
}

plugins/special-chars.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ codeInput.plugins.SpecialChars = class extends codeInput.Plugin {
100100

101101
// Create element with hex code
102102
let result = document.createElement("span");
103+
result.textContent = matchChar;
103104
result.classList.add("code-input_special-char");
104105
result.style.setProperty("--hex-0", "var(--code-input_special-chars_" + hexCode[0] + ")");
105106
result.style.setProperty("--hex-1", "var(--code-input_special-chars_" + hexCode[1] + ")");
@@ -189,4 +190,4 @@ codeInput.plugins.SpecialChars = class extends codeInput.Plugin {
189190

190191
return width;
191192
}
192-
}
193+
}

0 commit comments

Comments
 (0)