From de8fd9328e9deb0d1ec596d7486686ea3cb688c2 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Tue, 9 Jun 2020 18:27:38 +0200 Subject: Includes cmark markdown parser library. --- lib/cmark/wrappers/wrapper.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 lib/cmark/wrappers/wrapper.rb (limited to 'lib/cmark/wrappers/wrapper.rb') diff --git a/lib/cmark/wrappers/wrapper.rb b/lib/cmark/wrappers/wrapper.rb new file mode 100755 index 0000000..2359366 --- /dev/null +++ b/lib/cmark/wrappers/wrapper.rb @@ -0,0 +1,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())) -- cgit v1.2.3