 path = require 'path'
-_ = require 'underscore-plus'
 cheerio = require 'cheerio'
 createDOMPurify = require 'dompurify'
 fs = require 'fs-plus'

highlighter = null
{resourcePath} = atom.getLoadSettings()
packagePath = path.dirname(__dirname)

exports.toDOMFragment = (text='', filePath, grammar, callback) ->
  render text, filePath, (error, html) ->

  o.innerHTML

convertCodeBlocksToAtomEditors = (domFragment, defaultLanguage='text') ->
  codeBlocks.clear()
  grammarSubscription?.dispose()
  grammarSubscription = atom.grammars.onDidAddGrammar ->
    codeBlocks.forEach (fenceName, editor) ->
      if grammar = atom.grammars.grammarForScopeName(scopeForFenceName(fenceName))
        editor.setGrammar(grammar)

  if fontFamily = atom.config.get('editor.fontFamily')
    for codeElement in domFragment.querySelectorAll('code')
      codeElement.style.fontFamily = fontFamily

