Skip to content

Instantly share code, notes, and snippets.

@nickdunn
Created February 2, 2011 15:36
Show Gist options
  • Save nickdunn/807857 to your computer and use it in GitHub Desktop.
Save nickdunn/807857 to your computer and use it in GitHub Desktop.
<?php
// ensure output is sent as XML
header('Content-Type: text/xml');
echo('<?xml version="1.0" encoding="utf-8" ?>');
include_once('markdown.php');
$handle = opendir('.');
echo('<files>');
while (false !== ($file = readdir($handle))){
$extension = strtolower(substr(strrchr($file, '.'), 1));
// only process markdown text files
if(!in_array($extension, array('txt', 'md', 'markdown'))) continue;
$text = file_get_contents($file);
echo('<file name="' . $file . '" last-modified="' . date("Y-m-d\TH:i:s", filemtime($file)) . '">' . Markdown($text) . '</file>');
}
echo('</files>');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment