summaryrefslogtreecommitdiff
path: root/wrappers/wrapper.rb
blob: 2359366f347b3e7ef5b20f97d329883de345f466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env ruby
require 'ffi'

module CMark
  extend FFI::Library
  ffi_lib ['libcmark', 'cmark']
  attach_function :cmark_markdown_to_html, [:string, :int, :int], :string
end

def markdown_to_html(s)
  len = s.bytesize
  CMark::cmark_markdown_to_html(s, len, 0)
end

STDOUT.write(markdown_to_html(ARGF.read()))