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

Regex doesn't work in syntax highlighting #364

Open
NotroDev opened this issue Aug 17, 2022 · 9 comments
Open

Regex doesn't work in syntax highlighting #364

NotroDev opened this issue Aug 17, 2022 · 9 comments

Comments

@NotroDev
Copy link

Hi.
I have this regex:
https://regex101.com/r/P3WGak/1
And everywhere it works, but not in syntax highlighting.
I have this:

<Span foreground="#FF5555">
	<Begin>(&amp;[clkmno])+</Begin>
	<End>((?&lt;!&quot;)&quot;(?!&quot;))|((?&lt;=&quot;&quot;)&quot;(?!&quot;))</End>
</Span>

And, as you can see:
obraz
It doesn't work. Why?

@siegfriedpammer
Copy link
Member

siegfriedpammer commented Aug 17, 2022

I don't have the time to look at the regex, but I can tell you how to achieve your goal:

<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<Span begin="&quot;&quot;" end="" />
</RuleSet>
</Span>

This matches "" as it's own nested span.

Hope this helps.

@NotroDev
Copy link
Author

I don't have the time to look at the regex, but I can tell you how to achieve your goal:

<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<Span begin="&quot;&quot;" end="" />
</RuleSet>
</Span>

This matches "" as it's own nested span.

Hope this helps.

Thanks, but I really can't get it to work. Where should I do this? What should I change in "" regex?

@siegfriedpammer
Copy link
Member

I am not yet sure what you are trying to achieve... Can you post a screenshot of what the colors and text should look like? Thanks!

@NotroDev
Copy link
Author

NotroDev commented Aug 26, 2022

I am not yet sure what you are trying to achieve... Can you post a screenshot of what the colors and text should look like? Thanks!

Hey, It should be like this
obraz

// Maybe I could somehow do "end on LAST quot" regex/something else?

@NotroDev
Copy link
Author

// Maybe I could somehow do "end on LAST quot" regex/something else?

Hmm... It was probably a good idea!
obraz

@siegfriedpammer
Copy link
Member

I will post a working example of what I had in mind in the evening.

@siegfriedpammer
Copy link
Member

I am not sure if I understand your use-case correctly, but this is what I would have used:

<?xml version="1.0"?>
<SyntaxDefinition name="Custom Highlighting" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
	<Color name="String" foreground="Blue" />
	
	<RuleSet>
		<Span color="String">
			<Begin foreground="Red">"</Begin>
			<End foreground="Red">"</End>
			<RuleSet>
				<Span begin="&quot;&quot;" end="" foreground="Orange" />
			</RuleSet>
		</Span>
	</RuleSet>
</SyntaxDefinition>

Example:
image

Yes, I am not sure why you want to start the span on (&amp;[clkmno])+

By setting foreground directly on the Begin and End attributes of Span you can customize the color directly.

@NotroDev
Copy link
Author

Yes, I am not sure why you want to start the span on (&[clkmno])+

It's the color, &c = <red>
Yeah, thanks for it, but I think that my regex is a better solution.
Thanks for taking your time!

@NotroDev
Copy link
Author

Hey.
Oh my god, it was 24 days!
I returned to my project and I need to reopen this 😢
When I get the idea to get the last quote, I didn't think of one situation: two or more "".
It breaks completely in it...
obraz

I can't use your solution. E.g. &c is the color code, and in my editor it previews it.

@NotroDev NotroDev reopened this Sep 19, 2022
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

2 participants