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

Yoko Oh Noes should report any content after </body> as an error. #517

Open
DanJFletcher opened this issue Dec 11, 2015 · 6 comments
Open

Comments

@DanJFletcher
Copy link

One of the most common issues reported in the HTML/CSS challenges is caused from users creating nodes before or after the <body> and </body> tags (after being the most common).

It's possible to change each grader to display a message such as:
"It looks like you are trying to place your content after the </body> tag. Make sure your content sits between the <body> and </body> tags."

However this does not prevent the HTML from rendering in the output window, which is what I think is confusing students so much, and it's not valid HTML anyways.

Slowparse should see the following as a syntax error and give an appropriate message.
<body></body>node</html> as well as <body></body></html>node

All though the examples will technically render in a browser W3C will give, "Error: Non-space character after body." followed by "Fatal Error: Cannot recover after last error. Any further errors will be ignored." when ran through their validator.

To limit user confusion, and to encourage writing valid HTML, this should be seen as an error at KA.

@kevinbarabash
Copy link
Contributor

I tried the examples in http://mozilla.github.io/slowparse/ but slowparse didn't report any errors. Probably the most sensible path forward is try to add this check to our copy of slowparse. I would like to someday push our changes upstream.

@DanJFletcher
Copy link
Author

OK, I'll see if I can make those changes and will post a PR if it pans out. Likely sometime tonight or over the weekend.

@kevinbarabash
Copy link
Contributor

Thanks for looking into this.

@DanJFletcher
Copy link
Author

Your welcome. I took a look at the source code over the weekend, but I'm having trouble understanding where the syntax errors are being created.

I can see that there are factory functions in slowparse for each parse error, and that in live-editor.output_webpage.js there are lint messages. I'm not familiar with backbone, so maybe this is where my confusion is, but I can't seem to find where the errors are being used.

Slowparse doesn't seem to have any effect on the output. I can completely remove parse errors, and nothing seems to break. For example:

I removed INVALID_TAG_NAME from parseErrorBuilders, and even removed each "throws" for INVALID_TAG_NAME and yet the error is still caught and Oh Noes, still says the appropriate message when I use an invalid tag name.

I also see that postMessage() is somehow used to communicate with webpageOutput but I don't really understand how, other than it is used in the html worker.

Any clue where I look to get started with this?

@kevinbarabash
Copy link
Contributor

When making changes always, make changes in js/ instead of build/ and run gulp to continually watching the files. output.js lives in an iframe and communicates errors back to the parent frame via phoneHome which is called buildDone in js/output/shared/output.js. In the webpage environment this.output in output.js is an instance of WebpageOutput. Calls to LiveEditorOutput to lint and run the code are forwarded to WebpageOutput and results are returned back to LiveEditorOutput.

@DanJFletcher
Copy link
Author

Ah OK thanks!

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

2 participants