Accessing the document object

Hi all, I’m trying to create the option to have highlighted code in my card and it’s proving trickier than expected.

Here is my template so far…

<link rel="stylesheet" href="">
	<pre class="spacing"><code id="content" class="code">{{Code}}</code></pre>

<script src=""></script>

  "before:highlightElement": ({ el }) => { el.textContent = el.innerText } });

	// hljs.configure({tabReplace: '    '});

//	document.body.addEventListener("DOMContentLoaded", () => {
		const codeBlock = document.getElementById("content").innerHTML;

		function tab() {
			const modBlock = codeBlock.replace(/\t/g, "    ")
			console.log('modded bébé', modBlock)
			codeBlock.innerHTML = modBlock;

// })




I imagine I need to wait until the relevant dom elements have been loaded in before calling the tab() function, but whenever I try to place the code in the DOMContentLoaded event, the code doesn’t fire.

Btw what is the code language in the template? I’ve never seen {{template_name}} in straight up html…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.