code plugin: Add a language class to specify which language this code block is from.

This commit is contained in:
Emmanuel Gil Peyrot 2019-02-28 22:05:57 +01:00
parent 470696063d
commit f7e3e003a2

View file

@ -43,6 +43,6 @@ class Plugin(BasePlugin):
def command_code(self, args):
language, code = args.split(None, 1)
lexer = get_lexer_by_name(language)
room = self.api.current_tab()
tab = self.api.current_tab()
code = highlight(code, lexer, FORMATTER)
room.command_xhtml('<pre>%s</pre>' % code.rstrip('\n'))
tab.command_xhtml('<pre><code class="language-%s">%s</code></pre>' % (language, code.rstrip('\n')))