javascripthtmlangularjsgithub-api

how to convert a raw readme file to html formated document after geting it from github in angular js


I used the following controller but how to format each line of the README.MD raw file to html document

    angular.module('ExampleApp', [])
  .controller('ExampleController', function($scope, Slim,$sce) {
    Slim.getReadme().then(function(resp) {
      $scope.readme = $sce.trustAsHtml(resp.data);
    }).catch(function(resp) {
      console.log("catch", resp);
    });
  })
  .service('Slim', function($http) {
    return {
      getReadme: function() {
        return $http.get("https://api.github.com/repos/btford/angular-markdown-directive/readme", {
          headers: {
            "Accept": "application/vnd.github.v3.raw"
          }
        });
      }
    };
  });

I would be excited to know transformation of raw readme file to a formatted html page


Solution

  • ..how to format each line of the README.MD raw file to html document..

    Response you are getting from github API is plain markdown. So you just need to:

    What you do in parseMD is really upto you, its just a matter of choice. Here are some popular markdown-to-HTML libraries:

    All these libraries seem to go well with Github Flavored Markdown

    Here's the DEMO