vermiculus / sx.el

Stack Exchange for Emacs
http://stackapps.com/q/3950
709 stars 40 forks source link

Robustly determine major mode for code blocks #146

Open vermiculus opened 9 years ago

vermiculus commented 9 years ago

Came up in #141. The correct way to do this would be to deduce the major mode thusly:

  1. Is there a <!-- language: * --> line above our code block? If so, use that mode. (We could create an alist here if necessary.)
  2. Query SE for the language relation based on tags. There doesn't seem to be a way to do this yet, but if I'm not mistaken this is the way it's done normally.
  3. Use this structure to do the final guessing if necessary.
Malabarba commented 9 years ago

This answer has a list of lang-X tag for each language. http://meta.stackexchange.com/a/184109

vermiculus commented 9 years ago

SE uses the Prettifier JS library, so this will probably be a better resource as time goes on. That assumes they keep their library up-to-date, though.