8000 Fix extra spaces in static_cast in rtw_stb_image.h once fixed in Markdeep · Issue #1463 · RayTracing/raytracing.github.io · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Closed
hollasch opened this issue Mar 27, 2024 · 8 comments
Closed
Assignees
Milestone

Comments

@hollasch
Copy link
Collaborator

Markdeep currently has a bug where the line

*bptr = static_cast<unsigned char>(*fptr * 256.0);

is rendered as

*bptr = static_cast<unsigned char="">(*fptr * 256.0);

As a workaround, we use

*bptr = static_cast< unsigned char >(*fptr * 256.0);

This is in the file rtw_stb_image.h. Once this bug is fixed in Markdeep, remove the extraneous spaces inside the angle brackets.

@hollasch hollasch added this to the Backlog milestone Mar 27, 2024
@hollasch hollasch self-assigned this Mar 27, 2024
hollasch added a commit that referenced this issue Mar 27, 2024
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.
@armansito
Copy link
Contributor
armansito commented Mar 27, 2024

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 &#xFEFF;:

*bptr = static_cast<&#xFEFF;unsigned char>(*fptr * 256.0);

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 >) doesn't seem to be necessary as just separating the less-than sign from a subsequent character seems to be enough to convince the browser that this is not an HTML tag.

@hollasch
Copy link
Collaborator Author

Now copy and paste from the listing into your code and try compiling. 😄

@hollasch
Copy link
Collaborator Author

(I also tried no-break space, en-space, etc.)

@armansito
Copy link
Contributor

Yeah, copying and pasting becomes an issue with character codes like this.

8000
@armansito
Copy link
Contributor

Another solution that works (according to the Markdeep Demo, Section 1.15.5 is to wrap the code examples (or the entire document) in <script type="preformatted">...</script>. This seems to make the code render correctly without any special treatment and the copying and pasting seems to work as well.

@hollasch
Copy link
Collaborator Author

Ah. Ugly, but another decent (temporary) workaround. Morgan returns from vacation April 4 — let's see what his response is then.

@armansito
Copy link
Contributor

Another solution that works (according to the Markdeep Demo, Section 1.15.5 is to wrap the code examples (or the entire document) in <script type="preformatted">...</script>. This seems to make the code render correctly without any special treatment and the copying and pasting seems to work as well.

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.

hollasch added a commit that referenced this issue Mar 29, 2024
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.
@hollasch hollasch modified the milestones: Backlog, v4.0.0 Apr 10, 2024
@hollasch
Copy link
Collaborator Author

Here's Morgan's response:

This is caused by the browser parsing that as a HTML tag with an empty attribute before I see the document in Markdeep script. The simplest workaround is to make the input not legal HTML with the space as you found. Another workaround is the one advocated in the demo/manual https://casual-effects.com/markdeep/features.md.html#basicformatting/codeblocks/less-thansignsincode:

use a script tag with "preformatted" to surround either the entire document or the code sample. That prevents the browser from modifying it, and then Markdeep knows to strip the script tag out when processing.

hollasch added a commit that referenced this issue Apr 10, 2024
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
hollasch added a commit that referenced this issue Apr 10, 2024
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
< 4FA7 div class="js-timeline-marker js-socket-channel js-updatable-content" id="partial-timeline" data-channel="eyJjIjoiaXNzdWU6MjIxMDE2NDYzMCIsInQiOjE3NDg3NzUxMDJ9--ecc5e034c2faa565b71337f4fe8ba7efb036c117458c1e9fd786bb57b7f70884" data-url="/RayTracing/raytracing.github.io/issues/1463/partials/unread_timeline?issue=1463&since=2024-04-15T21%3A26%3A53.000000000-07%3A00" data-last-modified="2024-04-15T21:26:53.000000000-07:00" data-morpheus-enabled="false" data-gid="I_kwDOC8gc7M6DvG-W">
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
0