DESTINATION_HTML\n"); } $lines = file($argv[1]); $out = ''; $in_list = $in_section = false; $section_class = null; function escape($str) { $str = htmlspecialchars($str); $str = str_replace('<!--', '', $str); $str = str_replace('-->', '', $str); $str = preg_replace_callback('/`(.*?)`/', function ($match) { return '' . $match[1] . ''; }, $str); $str = preg_replace_callback('/\[(.*?)\]\((.*?)\)/', function ($match) { return sprintf('%s', $match[2], $match[1]); }, $str); return $str; } foreach ($lines as $line) { if (preg_match('/^---+(?:\s*=(\w+))?$/', $line, $match)) { if ($in_section) { if ($in_list) { $out .= ' ' . PHP_EOL; $in_list = false; } $out .= '' . PHP_EOL . PHP_EOL; $in_section = false; } $section_class = !empty($match[1]) ? $match[1] : null; continue; } if ('' === trim($line)) { continue; } if (!$in_section) { $out .= sprintf('
', $section_class) . PHP_EOL; $in_section = true; } if (preg_match('/^(#+)\s+/', $line, $match)) { $size = strlen($match[1]); $title = trim(substr($line, strlen($match[0]))); $out .= sprintf(' %s', $size, escape($title), $size) . PHP_EOL; } elseif (preg_match('/^\*\s+/', $line)) { if (!$in_list) { $out .= ' ' . PHP_EOL; $in_list = false; } $out .= '
' . PHP_EOL . PHP_EOL; $in_section = false; } ?> Slides