Display attributes with double quotes inside using single quotes
Opened this issue · 4 comments
tommie commented
Object literals in the code snippets look better if they don't contain " escaping. E.g. using
// Attributes with embedded JSON look better with apostrophes.
snippet = snippet.replace(/="[^"]*"[^"]*"/g, function(s) {
// If there are apostrophes, be safe and don't fiddle with it.
if (s.indexOf("'") !== -1 || s.indexOf(''') !== -1)
return s;
return s.replace(/"/g, "'").replace(/"/g, '"');
});
This should not have more false-positives than the empty attribute removal already in place.
eugef commented
Any plans to implement this fix?
notwaldorf commented
There's no PR for this at the moment. I would tend to prefer less magic in that regex, but if it came with a bunch of tests, I would review it :)
csonnhalter commented
I think tommi's snippet works fine, I tested it on jsbin: https://jsbin.com/berezuc/edit?html,js,output. Nice looking object literals would be really helpful for me.
super-kamil commented