3

Why does the Perl code formatting seem to be so broken?

Take this question for example: after the line $value //= qr{}; we can see that the code formatting is completely messed up until the user happens to include another backslash in a comment.

Another example is this post on Stack Overflow

This is a pretty good example of something that seems to happen a lot with Perl questions — often, after a backslash is entered, the code formatting seems to break entirely for the rest of the question. Even in areas where no backslashes are used, the formatting seems to have been poorly implemented and doesn't highlight commonly used keywords and functions as it might in other languages.

3

1 Answer 1

1

I think the best thing to do here is to let this one go, and accept that only a subset of perl is supported.


It could be because it thinks anything between two forward slashes is a regex pattern and highlights it as a string literal? In which case I don't get how any syntax highlighting script would determine the difference between a logical defined-or and a regex pattern that can be placed over multiple lines.

5
  • You might think so but I have never seen a text editor have any trouble highlighting Perl syntax. I just think that it's a lazy implementation that ought to be fixed. Perhaps SO should move away from Google Pretify? That's probably a lot to ask though and not something they would actually consider.
    – jess
    Feb 18, 2016 at 15:09
  • a lazy implementation I don't know about you, but I've made a couple of very basic syntax highlighters for easy languages like VBA and there is certainly nothing lazy about any of the implementation! It might not be as good as other highlighters out there, but credit where credit it due considering it's free! Feb 18, 2016 at 15:18
  • The highlighting works great for many other languages - I've posted a few C questions that have had perfect highlighting and I'm not here to dispute that. My qualm is that in the specific case of Perl they seem to have done half the job and just left it which seems like something they should have fixed by now as so many other tools exist that do this job perfectly, especially since they list it as supported in their documentation. All the same, I doubt anything will come of this unfortunately :(
    – jess
    Feb 18, 2016 at 15:27
  • @psychedelic_alex: Let me be the first to dispute that the C highlighter is perfect. Try continuing a line-comment on the next line, or what happens with C++ but not C keywords (nullptr, class, ...) as a start. Feb 18, 2016 at 16:20
  • Perhaps this is just even more reason that the SO team should move away from Google prettify to a platform that supports everyones interests, don't you think? C all seems to work fine for me, but I can't speak for C++ as I don't use it. Could you provide some examples of C++ formatting failing? If it's a larger issue than I originally realised then perhaps the SO team would take some interest in fixing it.
    – jess
    Feb 18, 2016 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .