Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display attributes with double quotes inside using single quotes #17

Open
tommie opened this issue Feb 25, 2016 · 4 comments
Open

Display attributes with double quotes inside using single quotes #17

tommie opened this issue Feb 25, 2016 · 4 comments

Comments

@tommie
Copy link

tommie commented Feb 25, 2016

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
Copy link

eugef commented Nov 11, 2016

Any plans to implement this fix?

@notwaldorf
Copy link
Contributor

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
Copy link

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
Copy link

super-kamil commented Feb 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants