There are a lot of tools that automatically detect the programming language used in code blocks and add proper syntax highlighting. For example: Highlight.js and google-code-prettify.
Given that using those is fairly straightforward (add bit of CSS and JS to your site), I suggested to a documentation team that they should incorporate it in their documentation HTML output. They told me this was not possible for accessibility reasons - for example, people that use screen readers may have trouble reading the code.
It's very hard for me (a person that doesn't use screen readers) to read source code without syntax highlighting. I usually need to copy/paste it to my text editor. That is not ideal from a UX standpoint. I assume other people will run into the same issue.
What are considered best practices regarding syntax highlighting and accessibility? What would be the best approach to take from a UX standpoint? (e.g. a toogle/switch, code for the majority of users)