File: wrapper.rb

package info (click to toggle)
cmark 0.30.2-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,704 kB
  • sloc: ansic: 7,473; python: 918; makefile: 164; cpp: 23; perl: 21; ruby: 11; sh: 4
file content (15 lines) | stat: -rwxr-xr-x 316 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()))