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

Fix link to "Entropy (information theory)" Wikipedia entry #2566

Merged

Conversation

mckzm
Copy link
Contributor

@mckzm mckzm commented Mar 23, 2024

Make "Entropy and information theory" inline link compatible with older markdown implementations.

fixes #2565

Newer Markdown implementations (e.g. GitHub's as of this writing) properly render an inline link[0] whose link destination[1] includes parenthesis. Older ones fail, and, as a result, what should be rendered as:

href="https://en.wikipedia.org/wiki/Entropy_(information_theory)"

is instead rendered as:

href="https://en.wikipedia.org/wiki/Entropy_(information_theory"

(closing parenthesis elided/wrong URL)

Wrapping the link destination within angle brackets solves that issue in a way that should be forward-compatible.

[0] https://spec.commonmark.org/0.31.2/#inline-link
[1] https://spec.commonmark.org/0.31.2/#link-destination

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request:

Checklist

Change the space in the box to an x for those you have completed.
You can also fill these out after creating the pull request.
If you're unsure about any of them, don't hesitate to ask.
We're here to help!
This is simply a reminder of what we are going to look for before merging your change.

  • I have read the contribution guidelines.
  • I have linked any relevant existing issues/suggestions in the description above (include #??? in your description to reference an issue, where ??? is the issue number).
  • The pull request is requesting a merge into the develop branch.
  • I have added necessary documentation (if appropriate).
  • If I've added/modified/deleted a third-party system, I've updated the relevant license files.
  • I have added myself to the 'Community Contributors' section of csfieldguide/templates/appendices/contributors.html

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc.
Feel free to add any images that might be helpful to understand the initial problem/solution.

Make "Entropy and information theory" inline link compatible with older markdown implementations.

fixes uccser#2565

Newer Markdown implementations (e.g. GitHub's as of this writing) properly render an inline link[0] whose link destination[1] includes parenthesis. Older ones fail, and, as a result, what should be rendered as:

href="https://en.wikipedia.org/wiki/Entropy_(information_theory)"

is instead rendered as:

href="https://en.wikipedia.org/wiki/Entropy_(information_theory"

(closing parenthesis elided/wrong URL)

Wrapping the link destination within angle brackets solves that issue in a way that should be forward-compatible.

[0] https://spec.commonmark.org/0.31.2/#inline-link
[1] https://spec.commonmark.org/0.31.2/#link-destination
@jimbonothing64
Copy link
Contributor

Thanks @mckzm for spotting and documenting this.

Unfortunately, when visiting https://cs-field-guide.localhost/en/chapters/coding-introduction/further-reading/, I get a TemplateSyntaxError :

Could not parse the remainder: '<https://en.wikipedia.org/wiki/Entropy_(information_theory' from '<https://en.wikipedia.org/wiki/Entropy_(information_theory'

Here is line 14 (offending line) of the template:

14: 	<li><a href="{% url <https://en.wikipedia.org/wiki/Entropy_(information_theory %}" target="_blank">Entropy and information theory</a>&gt;)</li>

This could be a bug in verto, our markdown renderer, where it doesn't support this feature of markdown correctly. It's worth investigating.

@jimbonothing64
Copy link
Contributor

I've added a test to verto. It is a bug where links in <> are not rendered correctly. Your change should work, so once verto is fixed to support this markdown feature, I will approve your pull.

@mckzm, in the meantime, could you please add yourself to the to the 'Community Contributors' section of csfieldguide/templates/appendices/contributors.html in this commit?

@mckzm
Copy link
Contributor Author

mckzm commented Mar 28, 2024

Thanks @jimbonothing64.

I have just added myself to the tail of the 'Community Contributors' list and updated the PR.

I've found 5 more instances of the same "dangling paren" problem in various links - would you prefer me to file one issue & PR per instance, or group them all into a single one instead?

@jimbonothing64
Copy link
Contributor

jimbonothing64 commented Apr 18, 2024

Apologies for the delayed response. Your issue and pull request have raised some very interesting points and uncovered other interesting issues!

At some point, verto should be updated to better support links; fixing verto requires more work/time than I'm can dedicate to this problem.

@mckzm, we should move to your simpler solution, from #2565: replacing ( and ) with %28 and %29, respectively.

Could you please update your pull to replace both the initial link and also the extra 5 links you discovered?

Thanks heaps!

mckzm added 6 commits April 19, 2024 11:18
Switch link to Wikipedia's "Entropy (information theory)" page to use percent encoding for the inner parens:

%28 for opening paren: (
%29 for closing paren: )
Update [Parity](https://en.wikipedia.org/wiki/Parity_(mathematics)) to use percent encoding for the inner parens.
Update [Wikipedia &ndash; Abstraction](https://en.wikipedia.org/wiki/Abstraction_(computer_science)) to use percent encoding for the inner parens
Update [The Battleship problem](https://en.wikipedia.org/wiki/Battleship_(puzzle)) to use percent encoding for the inner parens
Update [graph](https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)) to use percent encoding for the inner parens
Update [Ray tracing on Wikipedia](https://en.wikipedia.org/wiki/Ray_tracing_(graphics)) to percent encode the inner parens
@mckzm
Copy link
Contributor Author

mckzm commented Apr 19, 2024

@jimbonothing64 all done :-)

Copy link
Contributor

@jimbonothing64 jimbonothing64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much! One link has a typo, once that's fixed I'll merge your changes in. Thanks again!

Fix typo in percent encoding: &28 -> %28
Copy link
Contributor

@jimbonothing64 jimbonothing64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jimbonothing64 jimbonothing64 added this pull request to the merge queue Apr 19, 2024
Merged via the queue into uccser:develop with commit 226c958 Apr 19, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants