cmark

My personal build of CMark ✏️

wrapper.rb (316B)

 1 #!/usr/bin/env ruby
 2 require 'ffi'
 3 
 4 module CMark
 5   extend FFI::Library
 6   ffi_lib ['libcmark', 'cmark']
 7   attach_function :cmark_markdown_to_html, [:string, :int, :int], :string
 8 end
 9 
10 def markdown_to_html(s)
11   len = s.bytesize
12   CMark::cmark_markdown_to_html(s, len, 0)
13 end
14 
15 STDOUT.write(markdown_to_html(ARGF.read()))