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

(Swift) Incorrect highlighting of raw strings #2819

Closed
4 of 5 tasks
svanimpe opened this issue Nov 2, 2020 · 7 comments · Fixed by #2902
Closed
4 of 5 tasks

(Swift) Incorrect highlighting of raw strings #2819

svanimpe opened this issue Nov 2, 2020 · 7 comments · Fixed by #2902
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@svanimpe
Copy link
Contributor

svanimpe commented Nov 2, 2020

[Editor: Dropping some notes for whoever picks this up]

This needs to also take into account:

  • SUBST (inline code) inside raw strings
  • the different forms of escaping inside raw strings
  • the different syntax of variable substitution (we should probably highlight this, right?)
  • extend the string markup tests quite a bit to go along with this
  • could we handle arbitrary number of #### with END_SAME_AS_BEGIN? Worth it?

The following is a single raw string:

##"Use #" and "# to delimit a raw string."##

However, it's incorrectly highlighted as two separate strings. My guess is that highlight.js thinks the quotes in the middle close a string, then start a new one?

In general, the hashes around raw strings aren't highlighted in the same color as the string, so perhaps raw strings aren't supported at all yet?

@svanimpe svanimpe added bug help welcome Could use help from community language labels Nov 2, 2020
@joshgoebel
Copy link
Member

so perhaps raw strings aren't supported at all yet?

And we have a winner - seems not to be. :-) Want to work on a PR? :-)

@svanimpe
Copy link
Contributor Author

svanimpe commented Nov 2, 2020

I have a commit ready on https://github.com/svanimpe/highlight.js.

W.r.t. testing: I can sort of guess how the test cases work. Can I just add new files to test/markup/swift, or do I have to register them somewhere? And how do I run tests to verify that they work? (I'm not a JavaScript developer).

@joshgoebel
Copy link
Member

Can I just add new files to test/markup/swift,

Yes, you may want to consider renaming multiline-string to just strings and making it more general.

And how do I run tests

npm run build && npm run test-markup

@joshgoebel joshgoebel added the good first issue Should be easier for first time contributors label Nov 2, 2020
@joshgoebel
Copy link
Member

Note: The PR in #2820 is not a bad start.

@svanimpe
Copy link
Contributor Author

svanimpe commented Nov 2, 2020

To make it even more complex, escapes (such as \#t) and substitutions (such as \#(variable)) should also have the same number of hashes as the raw string delimiters used.

So #"something \#t and \#(variable) something"# contains a tab and a substitution, whereas ##"something \#t and \#(variable) something"## is fully raw (no tab and no substitution).

@joshgoebel
Copy link
Member

Annoying, but doable if we're only supporting a few specific variants... vs any number of ##### - which may not actually be possible given the contextual constraints you just mentioned.

@svanimpe
Copy link
Contributor Author

svanimpe commented Dec 2, 2020

Just FYI: I'm picking this up again. Expect a pull request soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants