I’m looking to manipulate/extract only the text contained within cloze deletions in my cards.
For example, in a card with the sentence: ‘‘Hast du {{c1::eigentlich}} Hobbies?’’, I want to target and extract only the word “eigentlich” without affecting the rest of the sentence.
With that, I want to create a TTS audio only with the word, but what I am getting is blank or . (punkt)
As you can see I used cloze-only, but only says “blank”.
{{cloze:Text}}
<br>
<br>
{{tts de_DE voices=Apple_Anna_(Premium):cloze-only:Text}}
<!----------------------------------------------------->
<script>
var currentCloze = document.querySelectorAll(".cloze");
// Hide the original cloze elements and create input boxes
for (i = 0; i < currentCloze.length; i++) {
currentCloze[i].style.display = "none";
const input = document.createElement("input");
input.type = "text";
input.classList.add("custom_typebox");
currentCloze[i].insertAdjacentElement("afterend", input);
}
var ctb = document.querySelectorAll('.custom_typebox');
// Iterate through custom_typebox elements to set placeholders and adjust widths
for (j = 0; j < ctb.length; j++) {
var text = document.getElementsByClassName('cloze')[j].innerText;
var result = text.replace("[...]", "");
var final_result = result.slice(1,-1);
ctb[j].placeholder = final_result;
// Create a hidden element to calculate the actual width of the placeholder
var hiddenElement = document.createElement('span');
hiddenElement.innerText = final_result;
hiddenElement.style.visibility = 'hidden';
hiddenElement.style.whiteSpace = 'pre'; // Preserve white spaces
// Insert the hidden element into the page and use it to calculate the actual width of the placeholder
document.body.appendChild(hiddenElement);
var placeholderWidth = hiddenElement.getBoundingClientRect().width;
// Remove the hidden element from the page
hiddenElement.parentNode.removeChild(hiddenElement);
// Set the width of the input field
ctb[j].style.width = placeholderWidth + 9 + "px";
}
</script>
The issue I was thinking of would be Droid-specific. But now that you’ve posted your template, hopefully someone else can take a look and see if there are any issues.