summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/tough-cookie/node_modules/punycode/vendor/docdown/doc/parse.php
blob: eca8d145e5d7ccf9bfab1477c6f969fb61ee71ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

  // cleanup requested filepath
  $file = isset($_GET['f']) ? $_GET['f'] : 'docdown';
  $file = preg_replace('#(\.*[\/])+#', '', $file);
  $file .= preg_match('/\.[a-z]+$/', $file) ? '' : '.php';

  // output filename
  if (isset($_GET['o'])) {
    $output = $_GET['o'];
  } else if (isset($_SERVER['argv'][1])) {
    $output = $_SERVER['argv'][1];
  } else {
    $output = basename($file);
  }

  /*--------------------------------------------------------------------------*/

  require('../docdown.php');

  // generate Markdown
  $markdown = docdown(array(
    'path' => '../' . $file,
    'title' => 'Docdown <sup>v1.0.0</sup>',
    'url'  => 'https://github.com/jdalton/docdown/blob/master/docdown.php'
  ));

  // save to a .md file
  file_put_contents($output . '.md', $markdown);

  // print
  header('Content-Type: text/plain;charset=utf-8');
  echo $markdown . PHP_EOL;

?>