可视化我网站中的README.md文件 [英] Visualizing README.md files in my website

查看:452
本文介绍了可视化我网站中的README.md文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站中可视化来自github中一个项目的README.md文件. 做这个的最好方式是什么?像获取降价代码并在本地处理降价一样?还是有一种方法可以从github获取已经处理过的markdown?

I want to visualize README.md files from a project in github, in my website. What is the best way to do this? Like fetch the markdown code and process the mark down locally? Or there is a way to fetch the already processed markdown from github?

推荐答案

一种可能的解决方案是使用基于JavaScript的降价解析器,例如

One possible solution is to use a javascript-based markdown parser, such as https://github.com/evilstreak/markdown-js.

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

That library can be loaded from the browser and can display the markdown. In this example (taken from the aforementioned site), you would need to fetch and insert the markdown in the output of your site:

<!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>

这篇关于可视化我网站中的README.md文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆