+
+ public function formatAnchor($anchor) {
+ if (is_numeric($anchor)) {
+ return "L$anchor";
+ }
+ return preg_replace("/[^[:alnum:]\.:_]/", ".", $anchor);
+ }
+
+ public function formatString($string) {
+ $md = \MarkdownDocument::createFromString($string);
+ $md->compile(\MarkdownDocument::AUTOLINK);
+ return $md->getHtml();
+ }
+
+ public function formatFile($file) {
+ $fd = fopen($file, "r");
+ $md = \MarkdownDocument::createFromStream($fd);
+ $md->compile(\MarkdownDocument::AUTOLINK | \MarkdownDocument::TOC);
+ $html = $md->getHtml();
+ fclose($fd);
+ return $html;
+ }