-
Notifications
You must be signed in to change notification settings - Fork 749
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
Alert when output and input text differ #852
Conversation
@miparnisari I had initially merged this into the branch of Rouge I was working on but was looking at various PRs again and am reconsidering. I have a couple of questions:
Pinging @mojavelinux in case he has some thoughts. |
When I tested my lexer I didn't find a way of knowing if I had inadvertently dropped a character or added an extra one. Maybe @jneen knows?
I don't remember exactly but I think it's very easy to drop newlines or whitespaces.
Ha, I thought a lot about this one when writing the Mason lexer. This lexer is currently being used in Production in my company, and I felt really scared of introducing a bug in the lexer that would incorrectly render the code. How on earth do you debug that?? :) I'm thinking of an ideal world where we in the backound do this check, and if there is a mismatch, we automatically submit a bug to rouge with the input file and the renderized file. But this introduces a whole set of problems. So I think consumers of rouge shouldn't know about this. We shouldn't let this kind of issues occur in the first place. This should be ran as part of the tests IMO.
Maybe not. It was my quick and dirty solution. A static element at the top could work too, but we need some way of automating this. |
@miparnisari I realise you've put quite a bit of work into this so this kind of comment will suck but I'm afraid I don't think the current approach of this PR is correct. In particular:
I must also confess that at a higher level I'm still not convinced this is a significant problem that we should be worried about. If you're writing lexers that are dropping characters, that suggests to me a mistake in the way that the lexer is being written. For lexers that subclass That said, my misgivings about this PR generally wouldn't stop me from merging it. I just worry that I'm missing something about this problem. |
It's been almost a year since I wrote my earlier comment and having been maintaining the library over that time I have now personally seen instances where this can occur. Typically it happens when a regular expression is matched but tokens are not assigned properly in the block that is passed to I need to think more about how to handle this on the server side, but I think there should be a way to check no characters have been dropped. |
I'm sorry it took me so long to look at this. @pyrmont If you check |
When viewing a sample, an alert will be shown if either there are errors in the rendering or if there is a difference between the "highlighted" and "raw" sections.
This fixes #850.