-
Notifications
You must be signed in to change notification settings - Fork 920
Fix extra spaces in static_cast in rtw_stb_image.h once fixed in Markdeep #1463
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
Comments
It turns out that a pattern like '<a b>' inside a code listing fools Markdeep into thinking it has an embedded HTML tag or something, and such a string will be expanded to '<a b="">'. Thus the line *bptr = static_cast<unsigned char>(*fptr * 256.0); gets transformed into *bptr = static_cast<unsigned char="">(*fptr * 256.0); when rendered. I've sent email to Morgan about this bug, but in the meantime, the best workaround I could come up with that can be safely copy-pasted and compiled is *bptr = static_cast< unsigned char >(*fptr * 256.0); That is, inserting spaces in the angle brackets. Somewhat ugly, but thankfully this is in rtw_stb_image.h, which the reader just uses as a gift instead of really working with. Issue #1463 tracks the work to undo this once it's fixed in Markdeep.
When you insert spaces those get rendered in the final document. To avoid the visible spaces and to prevent the browser from interpreting the less-than sign as the beginning of a tag, you can alternately insert a "Zero Width No-Break Space" unicode character (U+FEFF). The HTML entity escape code for this is
This gets rendered as expected and without spaces for me (by Chrome, Safari, and Firefox). Note that the second space (before the greater-than sign |
Now copy and paste from the listing into your code and try compiling. 😄 |
(I also tried no-break space, en-space, etc.) |
Yeah, copying and pasting becomes an issue with character codes like this. |
Another solution that works (according to the Markdeep Demo, Section 1.15.5 is to wrap the code examples (or the entire document) in |
Ah. Ugly, but another decent (temporary) workaround. Morgan returns from vacation April 4 — let's see what his response is then. |
I tried wrapping the whole document and that didn't work for me. Wrapping individual listings works though. Anyway, let's wait for Morgan's response. |
It turns out that a pattern like '<a b>' inside a code listing fools Markdeep into thinking it has an embedded HTML tag or something, and such a string will be expanded to '<a b="">'. Thus the line *bptr = static_cast<unsigned char>(*fptr * 256.0); gets transformed into *bptr = static_cast<unsigned char="">(*fptr * 256.0); when rendered. I've sent email to Morgan about this bug, but in the meantime, the best workaround I could come up with that can be safely copy-pasted and compiled is *bptr = static_cast< unsigned char >(*fptr * 256.0); That is 8000 , inserting spaces in the angle brackets. Somewhat ugly, but thankfully this is in rtw_stb_image.h, which the reader just uses as a gift instead of really working with. Issue #1463 tracks the work to undo this once it's fixed in Markdeep.
Here's Morgan's response:
|
When listing text contains something like static_cast<unsigned char>(thing) HTML parses `<unsigned char>` as an HTML tag before Markdeep gets a chance to see it. We had temporarily addressed this by adding spaces inside the angle brackets, and sent an inquiry off to Morgan McGuire, creator of Markdeep. His response was that Markdeep couldn't address this given the parsing order, and to just wrap the entire listing in <script type="preformatted"> ... </script> Resolves #1463
When listing text contains something like static_cast<unsigned char>(thing) HTML parses `<unsigned char>` as an HTML tag before Markdeep gets a chance to see it. We had temporarily addressed this by adding spaces inside the angle brackets, and sent an inquiry off to Morgan McGuire, creator of Markdeep. His response was that Markdeep couldn't address this given the parsing order, and to just wrap the entire listing in <script type="preformatted"> ... </script> Resolves #1463
Markdeep currently has a bug where the line
is rendered as
As a workaround, we use
This is in the file
rtw_stb_image.h
. Once this bug is fixed in Markdeep, remove the extraneous spaces inside the angle brackets.The text was updated successfully, but these errors were encountered: