10

I'm continually seeing this problem in Docs where people use the triple ` and a language declaration to wrap their code

```php <?php some code here ?> ```

It's quite annoying because, when you wrap your code blocks in it, it actually has the opposite effect in that it disables syntax highlighting

Wrapped as described

No Syntax highlighting

Indented without wrapping

Syntax highlighting

As you can see, the system seems to figure it out pretty readily. Sadly, most people don't seem to know that in Docs, you can hint a language using this before your code block

<!-- language: sql -->

Can something be done to catch this and alert the user not to wrap code blocks like this? Or perhaps make it more obvious how to hint what type of code a block is?

2
  • 11
    Submissions that use formatting codes appropriate for some other site might be a result of user experience with other Markdown flavors... but it might also indicate copy+paste of Markdown from elsewhere. Such cases should be carefully inspected for plagiarism.
    – Ben Voigt
    Aug 31, 2016 at 14:19
  • related: meta.stackoverflow.com/a/260541/248058
    – Knu
    Sep 2, 2016 at 3:07

2 Answers 2

6

We should block the use of the backtick wrapper ``` altogether.

It doesn't make sense to use on SO, nor on docs.

Besides, the <!-- language: lang-lng --> tag works on both sites.

3
  • 7
    -1 - the HTML comment syntax is neither obvious, nor easy to remember, and as such is one of the more user-unfriendly parts of the authoring experience. Sep 2, 2016 at 0:07
  • 1
    @SeanVieira yeah, who knew that triple backticks was easy to remember and user friendly?
    – Braiam
    Sep 2, 2016 at 3:08
  • 1
    They are not any more intuitive than the 4 space indentation, but once introduced to the <code>```tag</code> syntax I doubt many people forget it. I've been on SO since right after the beta and I still have to look up the comment syntax. Just one data point, but there it is :-) Sep 2, 2016 at 3:44
5

How about we, oh I don't know, get Docs to actually use the hints in this Markdown the way CommonMark suggests? If there's a broken feature in the Docs implementation (of supporting fenced codeblocks, which was explicitly included where it doesn't yet work on SE proper), the correct thing to do is finish implementing the feature the right way. Not take it out because the unfinished version isn't as useful yet.

2
  • 1
    Here's the funny thing about this: it actually works that way now. It functionally works exactly like a <code> block. The issue here is that blocks syntax highlighting (which is not covered by CM that I can see). But you're right. There's inconstancy here.
    – Machavity Mod
    Sep 1, 2016 at 2:32
  • 2
    @Machavity: Right, the code block is implemented, but the highlighting isn't, nor the recommended use of the info text as a language hint. Sep 1, 2016 at 2:40

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