Currently, in Remarkup, code blocks highlight as PHP by default. Although this works OK for C-family languages, it's pretty bad/distracting when a code block is used to just, e.g,., format text. Somewhat often I use code blocks to either show how to write something in Remarkup, or do something like describe a Herald rule in a structured way:
Conditions: If [x] is [y] Actions: Do [z]
Highlighting this kind of thing as PHP makes a fairly unreadable mess of it, as a bunch of words get coloration. I think a smarter rule would probably be:
- If the block is in an inline comment on a diff, default to the language implied by the file (for instance, inlines on a .py file get Python highlighting by default).
- If the block is on a paste, default to the language of the paste.
- If the block is on a revision/commit, default to the majority / plurality language of the revision/commit? Not so sure about this one. Major issue I can think of is that a "PHP" revision may be majority/plurality HTML or CSS, and the highlighters are very different. This is probably hard to figure out, too, and could theoretically change over the course of a revision. Maybe better to leave this rule out.
- Anywhere else (no context to infer language from), don't highlight by default.
Do those rules seem reasonable?
In all case, users could still select a language explicitly with lang=..., and the language inference rules would still override this default (for example, we infer that blocks beginning with <?php are certainly PHP unless the user has said otherwise with lang=...).