Is there any way to add javascript code to html components inside the macro

I have been devoloping a confluence macro and was successful in testing it: I have got two doubts:
1: How to add contents which already use double quotes with stringbuilder
2: How to inject HTML components and add javascript code inside the macro?