Yeah,but here’s a simpler version demonstrating what I think you are looking for :
https://anvil.works/ide#clone:BY744Q2WHGUZGEAV=7JY57JDQ3JWFVMUK4L2OMA6C
Basically, I create a form with custom HTML and a JS function in it.
I drag that form onto my main form (just like a text box for example).
Entering text and clicking submit should update the element (you can pack it with formatting)
I put the italic checkbox in there just to demonstrate formatting outside of the text box.
Does that help at all?