} if (str_has_prefix($arg, '--')) { continue; } $fd = fopen($arg, 'r'); $title = $arg; break; } /* Input */ $input_chunks = array(); while (!feof($fd)) { $input_chunks[] = fread($fd, 16384); } $input = join('', $input_chunks); fclose($fd); /* Output */ $output = TextFormatter::format($input, 'textile'); $output = trim($output); if ($use_page) { anewt_include('page'); $page = new AnewtPage(); $page->enable_dublin_core = false; $page->content_type = 'application/xhtml+xml'; $page->charset = 'UTF-8'; $page->title = $title; $page->add_stylesheet_href_media('style.css', 'screen'); $page->append(ax_raw($output)); echo to_string($page), NL; } else { echo $output, NL; }
<?php error_reporting(E_ALL); require_once '../anewt.lib.php'; anewt_include('textformatting'); /* Simple text */ $input = 'This is a test.'; var_dump(TextFormatter::format($input)); var_dump(TextFormatter::format($input, 'raw')); var_dump(TextFormatter::format($input, 'specialchars')); var_dump(TextFormatter::format($input, 'entities')); var_dump(TextFormatter::format($input, 'textile')); /* HTML text (with leading whitespace!) */ $input = ' <p>This is a <strong>test</strong>.</p>'; var_dump(TextFormatter::format($input)); var_dump(TextFormatter::format($input, 'raw')); var_dump(TextFormatter::format($input, 'specialchars')); var_dump(TextFormatter::format($input, 'entities')); var_dump(TextFormatter::format($input, 'textile'));
<?php require_once dirname(__FILE__) . '/../anewt.lib.php'; define('ANEWT_TEXTILE_DEVELOPMENT', 1); anewt_include('page'); $p = new AnewtPage(); $p->set('title', 'Textile formatting test'); if (AnewtRequest::get_bool('debug')) { header('Content-type: text/plain'); $p->set('content_type', 'text/plain'); } else { list($base_url, $params) = AnewtUrl::parse(AnewtRequest::url()); $params['debug'] = '1'; $debug_url = AnewtUrl::build(array($base_url), $params); $p->append(ax_p(ax_a_href('(Page source for debugging)', $debug_url))); } anewt_include('textformatting'); anewt_include('textile'); $text = file_get_contents(dirname(__FILE__) . '/sample-text.txt'); $formatted_text = TextFormatter::format($text, 'textile'); $p->append(ax_raw($formatted_text)); $p->flush();