 
     cmd =  options.cmd or codeChunk.getAttribute('data-lang')
 
-    # check id and save outputDiv to @codeChunksData
-    idMatch = dataArgs.match(/\s*id\s*:\s*\"([^\"]*)\"/)
-
-    if !idMatch
+    # check id and save outputDiv & outputElement to @codeChunksData
+    id = options.id
+
+    if !id
       return atom.notifications.addError('Code chunk error', detail: 'id is not found or just updated.')
-    else
-      id = idMatch[1]
 
     codeChunk.classList.add('running')
     if @codeChunksData[id]

        running = @codeChunksData[id]?.running or false
        codeChunk.classList.add('running') if running

        outputDiv = @codeChunksData[id]?.outputDiv
        outputElement = @codeChunksData[id]?.outputElement


    # insert outputDiv and outputElement accordingly
    $ = cheerio.load(htmlContent, {decodeEntities: true})
    codeChunks = $('.code-chunk')
    jsCode = ''
    for codeChunk in codeChunks
      $codeChunk = $(codeChunk)
      dataArgs = $codeChunk.attr('data-args')

      options = null
      try
        allowUnsafeEval ->
          options = eval("({#{dataArgs}})")
      catch e
        continue

      id = options.id
      continue if !id

      cmd = options.cmd or $codeChunk.attr('data-lang')

      outputDiv = @codeChunksData[id]?.outputDiv
      outputElement = @codeChunksData[id]?.outputElement

      if outputDiv # append outputDiv result
        $codeChunk.append("<div class=\"output-div\">#{outputDiv.innerHTML}</div>")

      if outputElement
        $codeChunk.append("<div class=\"output-element\">#{outputElement.innerHTML}</div>")

      if cmd == 'javascript'
        code = $codeChunk.attr('data-code')
        jsCode += code + '\n'

    $.html() + "<script>#{jsCode}</script>"


  getHTMLContent: ({isForPrint, offline, useRelativeImagePath, phantomjsType})->
