Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visualizing README.md files in my website

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?

like image 555
Daniel Avatar asked Feb 16 '16 20:02

Daniel


1 Answers

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>
like image 99
wbeckler Avatar answered Oct 06 '22 00:10

wbeckler