markdown 自己搞一个浏览工具

注意!` ` 下不能有空行 ` `上也不能有空行 问题未解决

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery.min.js"></script>
    <script src="markdown.js"></script>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
    <style>

        code {
            margin:0;
            padding:1em;
            background:#F9F9F9;
            border:1px dashed #2F6FAB;
            display:block;
            white-space:pre;
            font-family:"Courier New", Courier, monospace;
            color:#666;
            line-height:1.5;
            overflow:auto;
        }
    </style>
</head>
<body>
<?php
session_start();
if (isset($_GET['mdpsd'])) {
    if ($_GET['mdpsd'] != "xienaizhong") {
    } else {
        $_SESSION['loginmd'] = "1";
    }
    header("Location:/doc");
}
if ($_SESSION['loginmd'] != "1") {
    exit("<form method='get'><input name='mdpsd'><input type='submit' value='提交'></form>");
}


?>


<textarea id="text-input" oninput="this.editor.update()"
          rows="6" cols="60" style="display: none;"><?php include $_GET['f'] . ""; ?></textarea>
<div id="preview"></div>

<script>
    function Editor(input, preview) {
        this.update = function () {
            preview.innerHTML = markdown.toHTML(input.value);
        };
        input.editor = this;
        this.update();
    }
    var $ = function (id) {
        return document.getElementById(id);
    };
    new Editor($("text-input"), $("preview"));


</script>

<hr>
<?php
$dir = __DIR__;
$file = scandir($dir);
$index = 1;
foreach ($file as $x) {
    if (strpos($x, ".md") >= 1) {
        echo "<a href='/doc?f=" . $x . "'>" . $x . "</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        if ($index % 4 == 0) {
            echo "<br>";
        }
        $index = $index +1;
    }
}
?>

</body>
</html>

转载于:https://www.cnblogs.com/aliblogs/p/5906415.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值