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