(string $markdown)
| 1 | <?php |
| 2 | |
| 3 | function markdownToHtml(string $markdown): string |
| 4 | { |
| 5 | $ffi = FFI::cdef( |
| 6 | 'char *cmark_markdown_to_html(const char *text, size_t len, int options);', |
| 7 | 'libcmark.so' |
| 8 | ); |
| 9 | |
| 10 | $pointerReturn = $ffi->cmark_markdown_to_html($markdown, strlen($markdown), 0); |
| 11 | $html = FFI::string($pointerReturn); |
| 12 | FFI::free($pointerReturn); |
| 13 | |
| 14 | return $html; |
| 15 | } |
| 16 | |
| 17 | $markdown = <<<'md' |
| 18 | # First level title |