aboutsummaryrefslogtreecommitdiff
path: root/lib/cmark/wrappers/wrapper.rb
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-09 18:27:38 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-09 18:27:38 +0200
commitde8fd9328e9deb0d1ec596d7486686ea3cb688c2 (patch)
tree9c25d7568dee522c1d2ed7b6d238d1dad54163f6 /lib/cmark/wrappers/wrapper.rb
parent661ddc244793102ee0720871c4edcd64f80bc744 (diff)
downloadkristall-de8fd9328e9deb0d1ec596d7486686ea3cb688c2.tar.gz
Includes cmark markdown parser library.
Diffstat (limited to 'lib/cmark/wrappers/wrapper.rb')
-rwxr-xr-xlib/cmark/wrappers/wrapper.rb15
1 files changed, 15 insertions, 0 deletions
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()))