To escape single quotes, use json_encode() to echo arrays in HTML5 data attributes.
printf('<article data-tags="%s">', htmlspecialchars(json_encode(array('html5', ...)), ENT_QUOTES, 'UTF-8'));
Or you can also using built-in
json_encode(array('html5', ...), JSON_HEX_APOS)