diff options
Diffstat (limited to 'plugins/code.py')
-rw-r--r-- | plugins/code.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/plugins/code.py b/plugins/code.py index fa04f758..8d9c57a3 100644 --- a/plugins/code.py +++ b/plugins/code.py @@ -41,8 +41,12 @@ class Plugin(BasePlugin): help='Sends syntax-highlighted code in the current tab') def command_code(self, args): - language, code = args.split(None, 1) + split = args.split(None, 1) + if len(split) != 2: + self.api.information('Usage: /code <language> <code>', 'Error') + return None + language, code = split 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'))) |