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