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

Multiline CSS & JS strings are not correctly highlighted #457

Closed
LeaVerou opened this issue Jan 8, 2015 · 10 comments
Closed

Multiline CSS & JS strings are not correctly highlighted #457

LeaVerou opened this issue Jan 8, 2015 · 10 comments

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Jan 8, 2015

One can have multiline CSS/JS strings by escaping them with \ at the end of the line. However, Prism does not highlight them correctly.

@Golmote
Copy link
Contributor

Golmote commented Jan 8, 2015

The bug for JS strings was already mentioned in #66. PR #417 should solve it.

Golmote added a commit to Golmote/prism that referenced this issue Jan 8, 2015
Golmote added a commit to Golmote/prism that referenced this issue Jan 8, 2015
@LeaVerou
Copy link
Member Author

Hey, I just tried to highlight this in the test drive page:

/**
 * Basic border-image demo
 */

div {
    border: 40px solid transparent;
    border-image: 33.334% url('data:image/svg+xml,<svg xmlns="http:%2F%2Fwww.w3.org%2F2000%2Fsvg" width="30" height="30"> \
                          <circle cx="5" cy="5" r="5" fill="#ab4"%2F><circle cx="15" cy="5" r="5" fill=" #655"%2F> \
                          <circle cx="25" cy="5" r="5" fill="#e07"%2F><circle cx="5" cy="15" r="5" fill=" #655"%2F> \
                          <circle cx="15" cy="15" r="5" fill="hsl(15, 25%, 75%)"%2F> \
                          <circle cx="25" cy="15" r="5" fill=" #655"%2F><circle cx="5" cy="25" r="5" fill="#fb3"%2F> \
                          <circle cx="15" cy="25" r="5" fill=" #655"%2F><circle cx="25" cy="25" r="5" fill="#58a"%2F><%2Fsvg>');
    padding: 1em;
    max-width: 20em;
    font: 130%/1.6 Baskerville, Palatino, serif;
}

div:nth-child(2) {
    margin-top: 1em;
    border-image-repeat: round;
}

And the multiline string wasn't highlighted...

@Golmote
Copy link
Contributor

Golmote commented Jan 20, 2015

This must be because I did not allowed multi-line urls. I did not notice they were handle as a separated token. I'll check it tonight.

But this makes me worry about another point: do you know why the selector and property tokens are before the string token?

@Golmote
Copy link
Contributor

Golmote commented Jan 20, 2015

Multi-line urls are supported now : e4a13e5

There is still the problem of the position of the string pattern, though. It prevents Prism from properly highlighting something like:

foo {
  content: 'foo:bar'
}

because foo: in the string is highlighted as a property...

Are you aware of any requirement for selector and property to be listed before string?

@LeaVerou
Copy link
Member Author

Can’t think of any reason for property to be before string. As for selector, perhaps if there's some pseudo-class in the future that accepts a string argument? Can't think of anything at this point.

Thanks for the commit btw!

@Golmote
Copy link
Contributor

Golmote commented Jan 21, 2015

I'll move the string pattern above the property one, then.

@LeaVerou
Copy link
Member Author

Thanks!!

@LeaVerou
Copy link
Member Author

Oh I remembered re: selectors: Attribute selectors would then break.

@Golmote
Copy link
Contributor

Golmote commented Jan 21, 2015

And that's a really good point!

@vkbansal
Copy link
Contributor

Just to put it out there, I'm working on stylus definition and have written selector definitions from ground up. I think it shall be able to solve the problem. Will open a PR as soon as it's ready.

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

No branches or pull requests

3 participants