Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

13
  • 8
    Alternatively: just remove the automation: let authors/editors set the displayed language manually Commented Nov 6 at 21:49
  • 2
    This. Please. Or rather remove the header! Detecting language is unreliable (my experience - xaml detected as php). Maybe showing language should be only done if language is specifed explicitly. Maybe you can have 2 small copy buttons to copy with attributions in comments (who ever needs or asks for this???) and copy ONLY code block? Then just don't show button if language is not specified? Commented Nov 7 at 14:30
  • 4
    Another example: shell languages. The bash syntax highlighting is close enough for other shells like zsh, csh, ksh, etc., but there are significant differences in the actual syntax. This question now has multiple blocks labelled bash, even though almost all of the code is specific to zsh. It's confusing. Commented Nov 8 at 13:10
  • so, the root cause is that the syntax highlighter needs more supported language tags? Commented Nov 13 at 8:37
  • 4
    @JulesKerssemakers It's never going to have enough. The root cause is that the internal name of the highlighting rules package used by the syntax highlighter should not be presented as the name of the language. Commented Nov 13 at 8:48
  • +1, but you may want to respond to the rationale stated in this comment: “we wanted to display the detected code language so that users would know the attribution commenting format. If the language is wrongly detected, the commenting might be wrong and we didn't want to break anyone's code.” In cases where the guess is wrong, but the correct option exists, displaying the guess aids editors in finding and correcting the problem. Commented Nov 14 at 14:11
  • 4
    @KRyan Not sure what to respond to there as that argument is complete nonsense which has been already pointed out in the following comments. "In order to optimize the experience for those who paste the code and press Compile without looking, with have mislabeled all code blocks on the site". a) Excellent choice of those for whom to optimize the experience, and b) It's not going to work even for them because, remember, they aren't looking. Commented Nov 14 at 14:22
  • @Sinatr Remember, you can manually specify the language used in syntax highlighting. Commented Nov 14 at 18:03
  • 4
    Codeblocks for Bash now include bash as their first line. So stupid. bash is a valid command, it starts a new shell. The misfeature breaks answers, especially those that say "put this in your .bashrc. Experienced users will spot the abomination, but a newbie might not. If he or she manually copies the codeblock and pastes into .bashrc as advised, this will create an infinite loop when Bash starts, not a nice situation. The detected code language shall not be glued to the code! Commented Nov 15 at 21:22
  • @KamilMaciorowski Not sure what you are talking about. The misdetected name of the language is not included as the part of the copied code. Commented Nov 17 at 10:37
  • 1
    @GSerg I wrote "if he or she manually copies the codeblock". My point is the name of the language (misdetected or not, irrelevant) looks like the very beginning of the code and if one chooses to select and copy the code manually then there is the risk he or she will copy the name along with the actual code provided by the author, not being aware the name was never meant to be inside the code. I gave the example where the name is a valid command and the described scenario may lead to very bad experience, not just to a syntax error. Commented Nov 17 at 10:57
  • 2
    @CoarseRosinflower, it's not mandatory to speciy language when inserting code snippets. It would be A LOT of work to wix what they did everywhere. The language detection is working terribly wrong. The comments (really?) with attributions are: 1) useless 2) can be inserted as text, rather then "comments". The rookie (obviously) developer didn't even realise the complexity of the problem when he took his decision without consulting with senior. Commented Nov 17 at 11:20
  • @GSerg The misdetected name is included in a manual copy with Ctrl-C. Commented Nov 21 at 21:38