]> git.mxchange.org Git - friendica.git/blob - include/markdownify/example.php
Merge pull request #1033 from annando/master
[friendica.git] / include / markdownify / example.php
1 <?php
2         error_reporting(E_ALL);
3         if (!empty($_POST['input'])) {
4                 include 'markdownify_extra.php';
5                 if (!isset($_POST['leap'])) {
6                         $leap = MDFY_LINKS_EACH_PARAGRAPH;
7                 } else {
8                         $leap = $_POST['leap'];
9                 }
10                 
11                 if (!isset($_POST['keepHTML'])) {
12                         $keephtml = MDFY_KEEPHTML;
13                 } else {
14                         $keephtml = $_POST['keepHTML'];
15                 }
16                 if (!empty($_POST['extra'])) {
17                         $md = new Markdownify_Extra($leap, MDFY_BODYWIDTH, $keephtml);
18                 } else {
19                         $md = new Markdownify($leap, MDFY_BODYWIDTH, $keephtml);
20                 }
21                 if (ini_get('magic_quotes_gpc')) {
22                         $_POST['input'] = stripslashes($_POST['input']);
23                 }
24                 $output = $md->parseString($_POST['input']);
25         } else {
26                 $_POST['input'] = '';
27         }
28 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
29 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
30         <head>
31                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
32                 <title>HTML to Markdown Converter</title>
33         </head>
34         <body>
35                 <?php if (empty($_POST['input'])): ?>
36                 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
37                         <fieldset>
38                                 <legend>HTML Input</legend>
39                                 <textarea style="width:100%;" cols="85" rows="40" name="input"><?php echo htmlspecialchars($_POST['input'], ENT_NOQUOTES, 'UTF-8'); ?></textarea>
40                         </fieldset>
41                         <label for="extra">Markdownify Extra: <input name="extra" checked="checked" id="extra" type="checkbox" value="1"  /></label>
42                         <label for="leap">Links after each block elem: <input name="leap" id="leap" type="checkbox" value="1"  /></label>
43                         <label for="keepHTML">keep HTML: <input name="keepHTML" id="keepHTML" type="checkbox" value="1" checked="checked" /></label>
44                         <input type="submit" name="submit" value="submit" />
45                 </form>
46                 <?php else: ?>
47                 <h1 style="text-align:right;"><a href="<?php echo $_SERVER['PHP_SELF']; ?>">BACK</a></h1>
48                 <pre><?php echo htmlspecialchars($output, ENT_NOQUOTES, 'UTF-8'); ?></pre>
49                 <?php endif; ?>
50         </body>
51 </html>