diff src/site.js @ 34:0fb3488a017d

show_text
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 04 Aug 2025 23:06:19 -0600
parents 1e7d855afde3
children d72b1dff01c9
line wrap: on
line diff
--- a/src/site.js	Mon Aug 04 15:56:23 2025 -0600
+++ b/src/site.js	Mon Aug 04 23:06:19 2025 -0600
@@ -131,16 +131,17 @@
 		let text = div.textContent;
 		text = text.replace(/\{([^|}]+)\|([^|}]+)\}/g, '<ruby>$1<rt>$2</rt></ruby>');
 		text = converter.render(text);
-		if( lang && div.getAttribute('role')==='assistant' ) {
+		div.innerHTML = text;
+		div.removeAttribute('markdown');
+		let parent = div.parentNode;
+		if( parent.getAttribute('role')==='assistant' ) {
 			mdDiv.innerHTML = text;
 			let rts = mdDiv.querySelectorAll('rt');
 			for( let rt of rts ) {
 				rt.remove();
 			}
 			//console.log(mdDiv.textContent);
-			text += `\n<p><audio controls preload=none src="/tts.mp3?lang=${lang}&voice=${voice}&text=${encodeURIComponent(mdDiv.textContent)}"></audio></p>\n`;
+			parent.querySelector('audio').src = `/tts.mp3?lang=${lang}&voice=${voice}&text=${encodeURIComponent(mdDiv.textContent)}`;
 		}
-		div.innerHTML = text;
-		div.removeAttribute('markdown');
 	}
 }