在我的网站中可视化 README.md 文件

Dan*_*iel 9 html markdown github

我想在我的网站上可视化来自 github 项目的 README.md 文件。做这个的最好方式是什么?喜欢获取降价代码并在本地处理降价?或者有没有办法从github获取已经处理过的降价?

小智 6

一种可能的解决方案是使用基于 javascript 的降价解析器,例如https://github.com/evilstreak/markdown-js

该库可以从浏览器加载并显示降价。在此示例中(取自上述站点),您需要在站点的输出中获取并插入降价:

<!DOCTYPE html>
<html>
  <body>
    <textarea id="text-input" oninput="this.editor.update()"
              rows="6" cols="60">Insert proxied **Markdown** here.</textarea>
    <div id="preview"> </div>
    <script src="lib/markdown.js"></script>
    <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>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)