In a file that I will call file-a.php I have created a shortcode which prints the following (simplified) HTML markup:
<div><a href="#"><span>Link text</span></a></div>
In file-b.php I recover the [shortcode] and put it into a javascript variable:
var myvariable = "<?php print do_shortcode('[shortcode]'); ?>";
This is the HTML markup which I get when I print "myvariable":
<div><a href="#"><span>Link text
In practice, when the first "/" is detected the markup is interrupted.
I have tried consulting several resources but have not found any solution yet. Please consider that my PHP and JS knowledge is circumscribed. Thank you if you can point me to a possible solution.