     fn 'html', 'Adds some HTML', (string) ->
       @add_component html value: string
 
+    ErrorComponent = React.createClass
+      render: -> React.DOM.pre {className: 'error'}, @props.message
+
     fn 'error', 'Shows a preformatted error message', (message) ->
-      $pre = $ '<pre class="error"/>'
-      $pre.text message
-      @add_rendered $pre
+      @add_component ErrorComponent {message}
 
     example = React.createClass
       render: -> React.DOM.div {className: 'example', onClick: @on_click}, @transferPropsTo source()

    else
      target.textContent = code

  help = (fns) ->
    documented_fns = (name for name, c of fns when c?.doc?)
    documented_fns.sort()
    $dl = $ '<dl/>'
    for cmd in documented_fns
      $tt = $ '<tt/>'
      $tt.text cmd
      $dt = $ '<dt/>'
      $dt.append $tt
      $dl.append $dt
      $dd = $ '<dd/>'
      $dd.text fns[cmd].doc
      $dl.append $dd
    $dl

  modules.create 'builtins', ({fn, cmd}) ->
    cmd 'help', 'Shows this help', (cmd) ->

  CodeMirror = require 'cm/codemirror'
  require 'cm/runmode'
  URI = require 'URIjs'
  _ = require 'underscore'
  marked = require 'marked'
  modules = require 'modules'
