           return
       else
         fns = @imported_context_fns
-      @add_rendered help(fns)
+      @add_component help(fns)
+
+    KeyBindingComponent = React.createClass
+      render: ->
+        React.DOM.table {}, _.map @props.keys, (command, key) =>
+          React.DOM.tr {}, [
+            React.DOM.th {}, _.map key.split('-'), (k) -> React.DOM.kbd {}, k
+            React.DOM.td {}, React.DOM.strong {}, command.name
+            React.DOM.td {}, command.doc
+          ]
 
     cmd 'keys', 'Shows the key bindings', ->
       all_keys = {}
+      # TODO some commands are functions instead of names
       build_map = (map) ->
         for key, command of map
-          unless key == 'fallthrough' or all_keys[key]?
-            all_keys[key] = command
+          fn = CodeMirror.commands[command]
+          unless key == 'fallthrough' or all_keys[key]? or not fn?
+            all_keys[key] = name: command, doc: fn.doc
         fallthroughs = map.fallthrough
         if fallthroughs?
           build_map CodeMirror.keyMap[name] for name in fallthroughs
       build_map CodeMirror.keyMap.lead
 
-      $table = $ '<table/>'
-      for key, command of all_keys
-        fn = CodeMirror.commands[command]
-        if fn
-          doc = fn.doc ? ''
-          kbd = key.split('-').map((k) -> "<kbd>#{k}</kbd>").join ' + '
-          $table.append "<tr><th>#{kbd}</th><td><strong>#{command}</strong></td><td>#{doc}</td></tr>"
-      @add_rendered $table
+      @add_component KeyBindingComponent keys: all_keys, commands: CodeMirror.commands
 
     fn 'In', 'Gets previous input', (n) ->
       @value @get_input_value n

        _.extend @current_options, options
      @value @current_options

    cmd 'permalink', 'Create a link to the code in the input cell above', (code) ->
      a = document.createElement 'a'
      a.href = location.href
      a.hash = null
      code ?= @previously_run()
      a.search = '?' + encodeURIComponent btoa code
      a.innerText = a.href
      @add_rendered a

    fn 'websocket', 'Runs commands from a web socket', (url) ->
      ws = new WebSocket url

      s ||= new String o
      @add_component source value: s, language: 'json'

    MarkdownComponent = React.createClass
      render: -> React.DOM.div className: 'user-html', dangerouslySetInnerHTML: __html: marked @props.value

    fn 'md', 'Renders Markdown', (string) ->
      @add_component MarkdownComponent value: string

    text = React.createClass
      render: -> React.DOM.p {}, @props.value
