diff options
author | Ronan Collobert <ronan@collobert.com> | 2014-03-19 17:02:06 +0400 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2014-03-19 17:02:06 +0400 |
commit | 446e48d75b9b1d60e3380687b4246a8d53a378a4 (patch) | |
tree | d5f23dcc3f814140adc77229e403cb7767032c8d /init.lua | |
parent | aeaae9d84179fc4aee6cf9328d1b84d198719424 (diff) |
added support for color ascii rendering
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 31 |
1 files changed, 6 insertions, 25 deletions
@@ -1,28 +1,9 @@ -local ffi = require 'ffi' +local sundown = require 'sundown.env' +local html = require 'sundown.html' +local ascii = require 'sundown.ascii' -require 'sundown.sdcdefs' -require 'sundown.htmlcdefs' - -local C = ffi.load(package.searchpath('libsundown', package.cpath)) -local sundown = {C=C} - -function sundown.render(txt) - local callbacks = ffi.new('struct sd_callbacks') - local options = ffi.new('struct sdhtml_renderopt') - C.sdhtml_renderer(callbacks, options, 0) - - local markdown = C.sd_markdown_new(0xfff, 16, callbacks, options) - - local outbuf = ffi.new('struct sd_buf') - outbuf.data = nil - outbuf.size = 0 - outbuf.asize = 0 - outbuf.unit = 64 - - C.sd_markdown_render(outbuf, ffi.cast('const char*', txt), #txt, markdown) - C.sd_markdown_free(markdown) - - return ffi.string(outbuf.data, outbuf.size) -end +sundown.render = html.render +sundown.renderHTML = html.render +sundown.renderASCII = ascii.render return sundown |