subrepo: subdir: "deps/cmark" merged: "5ba25ff" upstream: origin: "https://github.com/commonmark/cmark.git" branch: "0.30.3" commit: "5ba25ff" git-subrepo: version: "0.4.6" commit: "d4444b563"
16 lines
316 B
Ruby
Executable File
16 lines
316 B
Ruby
Executable File
#!/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()))
|