Hi,
I'm currently writing a plugin similar to OSM Categories to embed a map. Users specify locations on their posts, and then markers are generated on the map and filtered by post category.
Each marker has a popup that includes the post's excerpt. I'm having difficulty, however, parsing the excerpt returned - when a line break is included in the excerpt, the map breaks with the error message Uncaught SyntaxError: Unexpected token ILLEGAL .
$find_text = array("'",' />',';','<br />');
$replace_text = array("\'",'>','','');
$post_excerpt = str_replace($find_text,$replace_text,get_the_excerpt());
$show_excerpt_markup = ($show_excerpt)?"<p><small>".$post_excerpt."</small></p>":"";
echo "popupContentHTML = '".$show_thumbnail_markup.$show_title_markup.$show_excerpt_markup."';";
echo "var new_marker = addMarker(ll, popupContentHTML, layer);";
I parse the excerpt for characters that break the code in str_replace - which works for single quotes - but when I try to replace the br line break, the map still breaks. And the Syntax error only displays the echoed text up to the point at which it breaks, so I'm not sure if I'm replacing the correct characters. An example of excerpt text with one line break that returns an error after ">":
<img class="aligncenter size-full wp-image-1331" src="http://mappingthecommons.org/wp-content/uploads/2014/06/unGuide_documentation-25.jpg" alt="Primi sistemi di allarme" width="640" height="425">
Originariamente non esistevano sistemi d'allarme a Matera nonostante l'evidente esposizione al pericolo di alluvioni improvvise...
I'm also wondering if this could be a characteristic of the excerpt text itself? Please let me know if this is clear. I'll leave the page with the error message up temporarily here: http://mappingthecommons.org/mappa.
Thank you!