Welcome to mirror list, hosted at ThFree Co, Russian Federation.

html.lua - github.com/torch/sundown-ffi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 349cfec3746acc02b424346fb417e2ab7660e2cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local sundown = require 'sundown.env'
local ffi = require 'ffi'
local C = sundown.C

require 'sundown.sdcdefs'
require 'sundown.htmlcdefs'

local function render(txt)
   local callbacks = ffi.new('struct sd_callbacks')
   local options = ffi.new('struct sd_html_renderopt')
   C.sd_html_renderer(callbacks, options, 0)
   local markdown = C.sd_markdown_new(0xfff, 16, callbacks, options)

   local outbuf = C.sd_bufnew(64)
   C.sd_markdown_render(outbuf, ffi.cast('const char*', txt), #txt, markdown)
   C.sd_markdown_free(markdown)
   txt = ffi.string(outbuf.data, outbuf.size)
   C.sd_bufrelease(outbuf)

   return txt
end

return {render=render}