This improves the fix to #9017 in commit 7c4354646b An alternative would be to avoid backslash escaping `#` and `%` in URLs, and instead always add `fragile` to the slide environment.
7c4354646b
Closes #8992.