• 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>
    
  • 相关阅读:
    查看SQL Server被锁的表以及如何解锁【转】
    JQUERY的$(function(){})和window.onload=function(){}的区别【转】
    安装和使用Redis【转】
    RabbitMQ的简单应用【转】
    Redis集群的搭建【转】
    Spring--如何解决循环依赖
    分布式事务--2PC(两阶段提交)
    CAP理论
    JVM垃圾回收机制
    Redis面试题
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5906415.html
Copyright © 2020-2023  润新知