aboutsummaryrefslogtreecommitdiff
path: root/wrappers/wrapper.rb
blob: 59a9b87560e5ea9eb7ab33e60ba0318c3a19a9f8 (plain)
  1. #!/usr/bin/env ruby
  2. require 'ffi'
  3. module CMark
  4. extend FFI::Library
  5. ffi_lib ['libcmark', 'cmark']
  6. attach_function :cmark_markdown_to_html, [:string, :int], :string
  7. end
  8. def markdown_to_html(s)
  9. len = s.bytesize
  10. CMark::cmark_markdown_to_html(s, len)
  11. end
  12. STDOUT.write(markdown_to_html(ARGF.read()))