Example #1
0
function respondWithFormat($app, $html, $format)
{
    $res = $app->response();
    if ($format == 'json') {
        $parser = new mf2\Parser($html);
        $output = $parser->parse();
        $output['note'][] = "This JSON is automatically generated by parsing the microformats from the HTML representation of this page using the php-mf2 library.";
        $output['note'][] = "You can find the php-mf2 library at github.com/indieweb/php-mf2";
        $output['note'][] = "If you see a problem with the output, please let me know! (github.com/aaronpk/IndieNews/issues)";
        $res['Content-Type'] = 'application/json';
        $res->body(json_encode($output));
    } else {
        $res->body($html);
    }
}
Example #2
0
function parse_mf2(&$html, $base)
{
    $parser = new \mf2\Parser($html, $base);
    return $parser->parse();
}
Example #3
0
 /**
  * Parses a given set of HTML for Microformats 2 content
  * @param $content HTML to parse
  * @return array
  */
 static function parseContent($content)
 {
     $parser = new \mf2\Parser($content);
     return $parser->parse();
 }